Skip to content

Instantly share code, notes, and snippets.

@imduffy15
Last active December 22, 2015 12:28
Show Gist options
  • Select an option

  • Save imduffy15/6472252 to your computer and use it in GitHub Desktop.

Select an option

Save imduffy15/6472252 to your computer and use it in GitHub Desktop.
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