Converting userinfo authorization to a config var

This commit is contained in:
Curtis Castrapel 2019-05-07 15:31:42 -07:00
parent 65f594fc29
commit 0eacbd42d7
1 changed files with 7 additions and 1 deletions

View File

@ -112,11 +112,17 @@ def retrieve_user(user_api_url, access_token):
""" """
user_params = dict(access_token=access_token, schema='profile') user_params = dict(access_token=access_token, schema='profile')
headers = {}
if current_app.config.get('PING_INCLUDE_BEARER_TOKEN'):
headers = {'Authorization': f'Bearer {access_token}'}
# retrieve information about the current user. # retrieve information about the current user.
r = requests.get( r = requests.get(
user_api_url, user_api_url,
params=user_params, params=user_params,
headers={'Authorization': 'Bearer {}'.format(access_token)}) headers=headers,
)
profile = r.json() profile = r.json()
user = user_service.get_by_email(profile['email']) user = user_service.get_by_email(profile['email'])