Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token Authorization doesn't seem to be working #135

Open
sh-ghanique opened this issue Aug 9, 2023 · 2 comments
Open

Token Authorization doesn't seem to be working #135

sh-ghanique opened this issue Aug 9, 2023 · 2 comments

Comments

@sh-ghanique
Copy link

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

  1. Go to https://id.atlassian.com/manage/api-tokens
  2. Create a new API token.
  3. Copy the API token
  4. In the code above replace "Token as copied from https://id.atlassian.com/manage/api-tokens'" with the API token.
  5. 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)
@MunifTanjim
Copy link
Owner

Is that token for bitbucket or token for atlassian? Can you make api call without this library with that token?

@Brianzchen
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants