Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Adding auth code flow support for public client (#149)
Browse files Browse the repository at this point in the history
* Adding auth code flow support for public client
  • Loading branch information
abhidnya13 authored May 18, 2018
1 parent fe2010a commit d7d5fe9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions adal/authentication_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def token_func(self):

def acquire_token_with_authorization_code(self, authorization_code,
redirect_uri, resource,
client_id, client_secret):
client_id, client_secret=None):
'''Gets a token for a given resource via auhtorization code for a
server app.
Expand All @@ -190,8 +190,9 @@ def acquire_token_with_authorization_code(self, authorization_code,
:param str resource: A URI that identifies the resource for which the
token is valid.
:param str client_id: The OAuth client id of the calling application.
:param str client_secret: The OAuth client secret of the calling
application.
:param str client_secret: (only for confidential clients)The OAuth
client secret of the calling application. This parameter if not set,
defaults to None
:returns: dict with several keys, include "accessToken" and
"refreshToken".
'''
Expand Down
5 changes: 3 additions & 2 deletions adal/token_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,13 @@ def get_token_with_authorization_code(self, authorization_code, client_secret):
self._log.exception('Attempt to look for token in cache resulted in Error')
oauth_parameters = self._create_oauth_parameters(OAUTH2_GRANT_TYPE.AUTHORIZATION_CODE)
oauth_parameters[OAUTH2_PARAMETERS.CODE] = authorization_code
oauth_parameters[OAUTH2_PARAMETERS.CLIENT_SECRET] = client_secret

if client_secret is not None:
oauth_parameters[OAUTH2_PARAMETERS.CLIENT_SECRET] = client_secret
token = self._oauth_get_token(oauth_parameters)
self._cache_driver.add(token)
return token


def _get_token_with_refresh_token(self, refresh_token, resource, client_secret):

self._log.info("Getting a new token from a refresh token")
Expand Down

0 comments on commit d7d5fe9

Please sign in to comment.