added headers key to oauth_settings
This commit is contained in:
@@ -177,6 +177,7 @@ def imports_get_token(
|
|||||||
client_id,client_secret
|
client_id,client_secret
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
post_data = {"grant_type": "authorization_code",
|
post_data = {"grant_type": "authorization_code",
|
||||||
"code": code,
|
"code": code,
|
||||||
"redirect_uri": redirect_uri,
|
"redirect_uri": redirect_uri,
|
||||||
@@ -184,12 +185,14 @@ def imports_get_token(
|
|||||||
"client_id": client_id,
|
"client_id": client_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = {'Accept': 'application/json',
|
try:
|
||||||
'Api-Key': client_id,
|
headers = oauth_data['headers']
|
||||||
'Content-Type': 'application/json',
|
except KeyError:
|
||||||
'user-agent': 'sanderroosendaal'}
|
headers = {'Accept': 'application/json',
|
||||||
|
'Api-Key': client_id,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'user-agent': 'sanderroosendaal'}
|
||||||
|
|
||||||
|
|
||||||
if 'json' in oauth_data['content_type']:
|
if 'json' in oauth_data['content_type']:
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
base_uri,
|
base_uri,
|
||||||
@@ -201,9 +204,6 @@ def imports_get_token(
|
|||||||
data=post_data,
|
data=post_data,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
print response.status_code
|
|
||||||
print response.json()
|
|
||||||
|
|
||||||
if response.status_code == 200 or response.status_code == 201:
|
if response.status_code == 200 or response.status_code == 201:
|
||||||
token_json = response.json()
|
token_json = response.json()
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ oauth_data = {
|
|||||||
'client_id': RUNKEEPER_CLIENT_ID,
|
'client_id': RUNKEEPER_CLIENT_ID,
|
||||||
'client_secret': RUNKEEPER_CLIENT_SECRET,
|
'client_secret': RUNKEEPER_CLIENT_SECRET,
|
||||||
'redirect_uri': RUNKEEPER_REDIRECT_URI,
|
'redirect_uri': RUNKEEPER_REDIRECT_URI,
|
||||||
'autorization_uri': "https://www.runkeeper.com/opps/authorize",
|
'autorization_uri': "https://www.runkeeper.com/apps/authorize",
|
||||||
'content_type': 'application/x-www-form-urlencoded',
|
'content_type': 'application/x-www-form-urlencoded',
|
||||||
'tokenname': 'runkeepertoken',
|
'tokenname': 'runkeepertoken',
|
||||||
'refreshtokenname': None,
|
'refreshtokenname': None,
|
||||||
'expirydatename': None,
|
'expirydatename': None,
|
||||||
'bearer_auth': True,
|
'bearer_auth': True,
|
||||||
'base_url': "https://runkeeper.com/apps/token",
|
'base_url': "https://runkeeper.com/apps/token",
|
||||||
|
'headers': {'user-agent': 'sanderroosendaal'}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user