Add access_token if token in response_type param.

This commit is contained in:
juanifioren 2015-02-02 17:39:01 -03:00
parent 77d1bf86e8
commit c5e37e9fdb

View file

@ -102,6 +102,7 @@ class AuthorizeEndpoint(object):
code.scope = self.params.scope code.scope = self.params.scope
code.save() code.save()
# Create the response uri.
uri = self.params.redirect_uri + '?code={0}'.format(code.code) uri = self.params.redirect_uri + '?code={0}'.format(code.code)
else: # Implicit Flow else: # Implicit Flow
@ -123,13 +124,18 @@ class AuthorizeEndpoint(object):
id_token = encode_id_token( id_token = encode_id_token(
id_token_dic, self.client.client_secret) id_token_dic, self.client.client_secret)
# TODO: Check if response_type is 'id_token token' then # Create the response uri.
# add access_token to the fragment. uri = self.params.redirect_uri + \
uri = self.params.redirect_uri + '#token_type={0}&id_token={1}&expires_in={2}'.format( '#token_type={0}&id_token={1}&expires_in={2}'.format(
'bearer', 'bearer',
id_token, id_token,
60 * 10 60 * 10,
) )
# Check if response_type is 'id_token token' then
# add access_token to the fragment.
if self.params.response_type == 'id_token token':
uri += '&access_token={0}'.format(token.access_token)
except: except:
raise AuthorizeError( raise AuthorizeError(
self.params.redirect_uri, self.params.redirect_uri,
@ -137,8 +143,6 @@ class AuthorizeEndpoint(object):
self.grant_type) self.grant_type)
# Add state if present. # Add state if present.
uri = uri + \ uri += ('&state={0}'.format(self.params.state) if self.params.state else '')
('&state={0}'.format(self.params.state)
if self.params.state else '')
return uri return uri