Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-11512

Access token expires immediately

    XMLWordPrintable

Details

    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.

      Attachments

        1. 2100695892-200.PNG
          2100695892-200.PNG
          58 kB
        2. 2118012808-err2.PNG
          2118012808-err2.PNG
          101 kB
        3. 3578120323-err1.PNG
          3578120323-err1.PNG
          40 kB

        Activity

          People

            Unassigned Unassigned
            9f8d4180049e miahj
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: