From cfbb05530a29a8b4174defb006c2a7af3f65c7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 17 Oct 2017 12:14:12 +0200 Subject: [PATCH] Taken unrelated code out of try-body. The try-body should only contain code that can actually raise the caught exception. --- pillar/api/blender_id.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pillar/api/blender_id.py b/pillar/api/blender_id.py index d10831ae..9227c3b6 100644 --- a/pillar/api/blender_id.py +++ b/pillar/api/blender_id.py @@ -186,11 +186,14 @@ def fetch_blenderid_user() -> dict: bid_url = '%s/api/user' % blender_id_endpoint() log.debug('Fetching user info from %s', bid_url) + + credentials = current_app.config['OAUTH_CREDENTIALS']['blender-id'] + oauth_token = session['blender_id_oauth_token'] + oauth_session = OAuth2Session( + credentials['id'], credentials['secret'], + access_token=oauth_token) + try: - client_id = current_app.config['OAUTH_CREDENTIALS']['blender-id']['id'] - client_secret = current_app.config['OAUTH_CREDENTIALS']['blender-id']['secret'] - oauth_session = OAuth2Session( - client_id, client_secret, access_token=session['blender_id_oauth_token']) bid_resp = oauth_session.get(bid_url) except httplib2.HttpLib2Error: log.exception('Error getting %s from BlenderID', bid_url)