node-bitbucket
node-bitbucket copied to clipboard
Token Authorization doesn't seem to be working
What am I doing wrong here?
Consider the following code:
import { Bitbucket } from "bitbucket";
const apiToken = 'Token as copied from https://id.atlassian.com/manage/api-tokens';
const bitbucket = new Bitbucket({
baseUrl: 'https://api.bitbucket.org/2.0',
auth: {
token: apiToken,
}
});
const repos = bitbucket.user.get({}).then(value => {
console.log(value.data);
});
Steps to reproduce
- Go to https://id.atlassian.com/manage/api-tokens
- Create a new API token.
- Copy the API token
- In the code above replace "Token as copied from https://id.atlassian.com/manage/api-tokens'" with the API token.
- Run the code.
Expected
The current user is being logged.
Actual
BITBUCKET CLOUD API LATEST UPDATES: https://developer.atlassian.com/cloud/bitbucket
index.ts:11
Process exited with code 1
Uncaught i HTTPError: Unauthorized
at <anonymous> (/wrk/bitbucket/node_modules/bitbucket/src/request/fetch-wrapper.ts:48:17)
at processTicksAndRejections (internal/process/task_queues:95:5)
Is that token for bitbucket or token for atlassian? Can you make api call without this library with that token?
Same issue, having dug around and reading posts such as https://stackoverflow.com/questions/68597002/why-is-personal-access-token-not-working-for-bitbucket-rest-api it seems that bitbucket expects you to have both a token with a username. So I got it working by passing username and password=token