Our OAuth client issues user (3LO) access tokens successfully, but api.bitbucket.org rejects them on every endpoint. We’re trying to work out whether this is expected for this client type or a platform issue.
Flow
- Browser to Log in with Atlassian account
- User approves and is redirected back with ?code=…
- POST https://bitbucket.org/site/oauth2/access_token with HTTP Basic client auth, grant_type=authorization_code, code and redirect_uri
→ 200 OK: token_type=Bearer, expires_in=7200, a refresh_token, scope “pullrequest issue project repository account email” - GET https://api.bitbucket.org/2.0/user with “Authorization: Bearer <access_token>”
Expected: 200 with the user’s profile.
Actual: 401
{“type”:“error”,“error”:{“message”:“Token is invalid, expired, or not supported for this endpoint.”}}
The same 401 comes back for /2.0/user, /2.0/repositories?role=member&pagelen=1, /2.0/workspaces?pagelen=1 and /2.0/user/permissions/workspaces?pagelen=1.
What we found
- The access token is an Atlassian Identity JWT:
- iss = https://auth.atlassian.com
- scope = offline_access read:account:bitbucket-legacy read:email:bitbucket-legacy read:issue:bitbucket-legacy read:project:bitbucket-legacy read:pullrequest:bitbucket-legacy read:repository:bitbucket-legacy
- https://atlassian.com/3lo = true
- https://atlassian.com/authProfile = oauth.bitbucket.legacyOAuthPrivate (it was legacyOAuthPublic before we enabled “Client credentials” on the client)
- api.atlassian.com accepts the same token. GET /oauth/token/accessible-resources returns 200 with , and GET /me returns 403 insufficient scope (read:me). So the token authenticates on Atlassian’s side, and only api.bitbucket.org rejects it.
- The same client’s client_credentials (2LO) token works. GET /2.0/user returns 200 as the workspace system account.
- Refreshing the token returns a token of the same kind, with the same 401.
- We checked that the redirect URI, scopes, Basic client authentication and the “Authorization: Bearer” header all match the documentation. We also tried sending the token as ?access_token= and with a “JWT” scheme. Neither works.
- The client was created on the newer “OAuth clients” page. Workspace settings no longer has the classic “OAuth consumers” page for creating one.
Questions
- Is a user (3LO) access token from an OAuth client of this type expected to work against api.bitbucket.org/2.0? If so, how should it be sent?
- Is there a known issue with clients that have been migrated to, or generated on, the Atlassian identity platform?
- Is there a different supported way to get a user-scoped token that api.bitbucket.org accepts? We need one for pull request read access on behalf of a user.
Happy to share more detail, such as response headers or tim