Skip to content

Instantly share code, notes, and snippets.

@Seich
Created October 11, 2014 03:12
Show Gist options
  • Save Seich/58000caed7a7b01df055 to your computer and use it in GitHub Desktop.
Save Seich/58000caed7a7b01df055 to your computer and use it in GitHub Desktop.
def save_bearer_token(self, token, request, *args, **kwargs):
if request.old_token:
request.old_token.delete()
scopes = request.scopes
if type(scopes) is str:
scopes = request.scopes.split()
BearerToken(
client=request.client.key,
scopes=scopes,
user=request.user,
access_token=token['access_token'],
refresh_token=token['refresh_token'],
expires_at=datetime.datetime.now() + datetime.timedelta(hours=1)
).put()
return request.client.default_redirect_uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment