API Calls stuck on valid Token
AnsweredI'm grabbing a fresh access token, and I believe that it has the correct permissions. However when I do a `get`, it's coming back with `No valid API token provided`:
url: https://api.app.wdesk.com/platform/v1/users
headers:
user_headers = {
'Accept': 'application/vnd.api+json',
'Authorization': 'Bearer ' + bearer_token
}
r = requests.get(user_url, headers = user_headers)
print(r.json())
Results in:
{'code': '401Unauthorized', 'message': 'No valid API token provided'}
Am I missing something here?
0
-
Hi Nick, what does your code look like for requesting the bearer token? Please don't include your actual Client ID or Client Secret if you post your bearer token request code.
0host = 'api.app.wdesk.com'
path = '/iam/v1/oauth2/token'
bearer_headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'charset': 'UTF-8'
}
bearer_url = 'https://' + host + path
bearer_data = {'client_id':client_id, 'client_secret':secret, 'grant_type':'client_credentials'}
bearer_result = requests.post(bearer_url, data= bearer_data, headers=bearer_headers)
bearer_json = json.loads(x.text)
bearer_token = bearer_json['access_token']0Annnd.... realized I didn't carry the names through correctly. It's working now.
0Please sign in to leave a comment.
Comments
3 comments