Skip to content

Commit

Permalink
more on parametrization
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimiliano committed May 29, 2013
1 parent 8770608 commit 58dc376
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions oauth2_provider/oauth2_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ def validate_redirect_uri(self, client_id, redirect_uri, request, *args, **kwarg
return request.client.redirect_uri_allowed(redirect_uri)

def save_authorization_code(self, client_id, code, request, *args, **kwargs):
expires = timezone.now() + timedelta(seconds=60) # TODO put delta in settings
expires = timezone.now() + timedelta(seconds=oauth2_settings.AUTHORIZATION_CODE_EXPIRE_SECONDS)
g = Grant(application=request.client, user=self.user, code=code['code'], expires=expires,
redirect_uri=request.redirect_uri, scope=' '.join(request.scopes))
g.save()

def save_bearer_token(self, token, request, *args, **kwargs):
expires = timezone.now() + timedelta(seconds=36000) # TODO put delta in settings
expires = timezone.now() + timedelta(seconds=oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS)
access_token = AccessToken(
user=self.user, # TODO check why if response_type==token request.user is None
scope=token['scope'],
Expand All @@ -162,4 +162,5 @@ def save_bearer_token(self, token, request, *args, **kwargs):
)
refresh_token.save()

token['expires_in'] = 36000 # TODO put delta in settings
# TODO check out a more reliable way to communicate expire time to oauthlib
token['expires_in'] = oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS

This comment has been minimized.

Copy link
@leonid-s-usov

leonid-s-usov Dec 15, 2015

This is really a bad way, I am suggesting #338 to get rid of it

2 changes: 2 additions & 0 deletions oauth2_provider/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
'CLIENT_ID_GENERATOR_CLASS': 'oauth2_provider.generators.ClientIdGenerator',
'CLIENT_SECRET_GENERATOR_CLASS': 'oauth2_provider.generators.ClientSecretGenerator',
'SCOPES': [],
'AUTHORIZATION_CODE_EXPIRE_SECONDS': 60,
'ACCESS_TOKEN_EXPIRE_SECONDS': 36000,
}

# List of settings that cannot be empty
Expand Down

0 comments on commit 58dc376

Please sign in to comment.