Bearer Token header not working - 401 error
AnsweredHi,
I'm trying to do API calls using Bearer auth for cloud users.
I did all the following steps as mentioned in your documentation.
All steps were completed successfully and I also checked that I got the excepted output.
I'm using python requests.
I got the Bearer token that was returned from the API call (/cdb/oauth2/token) and put it in the headers.
My request looks like this:
-
Hello,
Please, try our python example on GitHub.
1 -
Hi,
Thanks for the quick reply!
I have already gone through your code, still not working for me, so I tried it by myself as follows:
1. Obtain the session token from the Cloud by OAuth2, using POST /cdb/oauth2/token request.
The output I got is:

As you can see, this response is correct.
2. I took the access token value from the returned response, and put it inside a dictionary that contains the header. This dictionary variable looks like this:

3. I did an API call for create new event, using the header with the access token:
As mentioned in my first post, when we did this API call with Digest auth, it worked good, so there is no problem with the API URL or with the params.4. After the create event API call, I printed the response content, and I got the following output:
I would appreciate your help, thanks!
0 -
Hi I tried to change the API call using the header with the access token from create new event to moduleInformation and it is work:
My question is does createEvent work in bearer token authentication ??I would appreciate your help, thanks!
0 -
Hi, until now I am waiting for your help
I would appreciate your help, thanks!
0 -
Hello,
My question is does createEvent work in bearer token authentication ??
Yes, it does. API endpoints don't depend on authentication schema.
Try to add the following parameter to requests.get method.
allow_redirects=True
0
Please sign in to leave a comment.
Comments
5 comments