Skip to content

Commit

Permalink
Establish a new connection every time talking to orcid enpoint (for e…
Browse files Browse the repository at this point in the history
…xchanging code for token)
  • Loading branch information
romanchyla committed Dec 12, 2019
1 parent df27729 commit 9f76147
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions orcid_service/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import pytz
import adsmutils
import requests

bp = Blueprint('orcid', __name__)

Expand All @@ -27,7 +28,11 @@ def get_access_token():
'grant_type': 'authorization_code'
}
#print current_app.config['ORCID_OAUTH_ENDPOINT'], data, headers
r = current_app.client.post(current_app.config['ORCID_OAUTH_ENDPOINT'], data=data, headers=headers)

# do not use connection pool, always establish a new connection to the orcid remote server
# we were having issue with dropped connectins mid-stream and this request is not idempotent
# therefore we can't retry
r = requests.post(current_app.config['ORCID_OAUTH_ENDPOINT'], data=data, headers=headers)
if r.status_code != 200:
logging.error('For ORCID code {}, there was an error getting the token from the ORCID API.'.
format(payload['code'][0]))
Expand Down Expand Up @@ -611,4 +616,4 @@ def find_record(work):
'putcode': putcode,
'source': sources
}
}
}

0 comments on commit 9f76147

Please sign in to comment.