Skip to content

Commit

Permalink
Merge pull request #206 from lepture/expires
Browse files Browse the repository at this point in the history
The ability to vary expires_in per request.
  • Loading branch information
ib-lundgren committed Sep 16, 2013
2 parents 25c82a2 + 27b480b commit 4234b53
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion oauthlib/oauth2/rfc6749/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,18 @@ def __init__(self, request_validator=None, token_generator=None,

def create_token(self, request, refresh_token=False):
"""Create a BearerToken, by default without refresh token."""

if callable(self.expires_in):
expires_in = self.expires_in(request)
else:
expires_in = self.expires_in

token = {
'access_token': self.token_generator(request),
'expires_in': self.expires_in,
'expires_in': expires_in,
'token_type': 'Bearer',
}

if request.scopes is not None:
token['scope'] = ' '.join(request.scopes)

Expand Down

0 comments on commit 4234b53

Please sign in to comment.