MunifTanjim / node-bitbucket

Bitbucket API client for Browser and Node.js
https://bitbucketjs.netlify.app
MIT License
106 stars 28 forks source link

Getting error code 403 Forbidden when trying to use bitbucket.projects.deleteProject #86

Open sw-dev-code opened 3 years ago

sw-dev-code commented 3 years ago

When I try to delete the Project I'm getting the 403 Forbidden code, even if I was able to DELETE the repositories in the previous step.

I'm able to delete the project from Postman using the same API as node-bitbucket is using.

Thank you in advance for the help.

MunifTanjim commented 3 years ago

Did you use the same credentials for all those operations?

403 Forbidden implies you're using a token which don't have permission to delete projects.

sw-dev-code commented 3 years ago

@MunifTanjim I'm not using the token, I'm using the admin username/password for all operations. That user are able to create a project on Bitbucket Cloud.

fran-kyso commented 2 years ago

Same is happening to me, but in my case for listing all the repositories of an user.

This is the code:

test("Get all repositories", async () => {
    const bucket = new ReposBitbucketProvider();

    bucket.withUserAndPassword("USERNAME@MAIL.COM", "PASSWORD");
    const result = await bucket.getRepos("test-kyso", 1, 5);

    expect(result.name).toBe('test');    
});

When withUserAndPassword is:

async withUserAndPassword(username, password) {
    this.bitbucket = new Bitbucket({
      auth: {
        username: username,
        password: password,
      },
    });
  }

and getRepos is:

async getRepos(workspace, page, perPage) {
    const { data, headers } = await this.bitbucket.repositories.list({
      workspace: workspace,
      page: page, 
      pagelen: perPage
    });

    return data.values.map(repoMapFunction)
  }

It's curious, because if I use my personal account of Bitbucket I can retrieve all the repositories, but if I create a new fresh account, I've got a 403 Forbidden message.

I reviewed the permissions of the user, and it's an owner of everything... so can't be a permissions issue.

Any thoughts?

Thanks a lot!