Last active
December 22, 2015 12:28
-
-
Save imduffy15/6472252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def required(f): | |
| @wraps(f) | |
| def decorated(*args, **kwargs): | |
| authorization = resource_provider.get_authorization() | |
| if not authorization.is_valid: | |
| return abort(401) | |
| else: | |
| """ Pass variables from authorization back to the calling function""" | |
| return f(*args, **kwargs) | |
| return decorated | |
| @app.route('/compute/v1beta15/projects/<projectid>') | |
| @authentication.required | |
| def getProject(projectid): | |
| resp = jsonify({ | |
| "userid": "Set this based on the variables given back by the decorator" | |
| }) | |
| resp.status_code = 200 | |
| return resp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment