some error checking in the get_token C2 routine
This commit is contained in:
@@ -329,6 +329,7 @@ def do_refresh_token(refreshtoken):
|
||||
|
||||
# Exchange authorization code for authorization token
|
||||
def get_token(code):
|
||||
messg=''
|
||||
scope = "user:read,results:write"
|
||||
client_auth = requests.auth.HTTPBasicAuth(C2_CLIENT_ID, C2_CLIENT_SECRET)
|
||||
post_data = {"grant_type": "authorization_code",
|
||||
@@ -349,11 +350,15 @@ def get_token(code):
|
||||
response = s.send(prepped)
|
||||
|
||||
token_json = response.json()
|
||||
thetoken = token_json['access_token']
|
||||
expires_in = token_json['expires_in']
|
||||
refresh_token = token_json['refresh_token']
|
||||
|
||||
return [thetoken,expires_in,refresh_token]
|
||||
if token_json['status_code'] == 200:
|
||||
thetoken = token_json['access_token']
|
||||
expires_in = token_json['expires_in']
|
||||
refresh_token = token_json['refresh_token']
|
||||
else:
|
||||
return (0,token_json['message'])
|
||||
|
||||
return (thetoken,expires_in,refresh_token,messg)
|
||||
|
||||
# Make URL for authorization and load it
|
||||
def make_authorization_url(request):
|
||||
|
||||
Reference in New Issue
Block a user