Details
-
Bug
-
Resolution: Fixed
-
Medium
Description
I am implementing a JS app that uses the Bitbucket REST api. I am trying to implement OAuth2 (implicit grant flow). After the user has already granted access to their account, I am getting back an access token as expected and I am using that in making the next call to retrieve the user details.
However I am getting the following (please note that this is a custom error message built using the url, status code and message returned from the bitbucket server)
https://api.bitbucket.org/2.0/user returned status code: 401 Access token expired. Use your refresh token to obtain a new access token.
I do not know what I am doing wrong here. To make matters worse and strange, if I start refreshing the app (after the 10th or so time) it suddenly decides to work, each time I get a 401 I attempt to get a new access token, so i am having to ask bitbucket for access token at least 10 times before I get a token that doesn't expire straight away.
This seems to be happening when I am using GET https://api.bitbucket.org/2.0/user endpoint. After trying it on a REST client, it seems to be asking me authenticate again despite having put the access token in the header
Please could someone tell me what is happening here or if I am doing anything wrong.