Home > front end >  How can I list scopes for Bitbucket app password?
How can I list scopes for Bitbucket app password?

Time:08-13

How do I list the scopes that my Bitbucket app password has access to? For example, I can then know if it has access to the repository:admin scope or not.

I checked the API doc for the /user endpoint, but it doesn't return me this info:

$ curl -u <username>:<app_password> https://api.bitbucket.org/2.0/user | jq

Is there an endpoint or any other way to retrieve it?

CodePudding user response:

If the goal is to determine which scopes a token has access to, check the response header with prefix x-oauth-scopes (using curl with -I):

$ curl -sS -f -I -u <username>:<app_password> https://api.bitbucket.org/ | grep ^x-oauth-scopes: | cut -d' ' -f2- | tr -d "[:space:]" | tr ',' '\n'

Note that tr -d "[:space:]" above is essential for removing some unusual whitespace, failing which a matching command such as grep -x doesn't subsequently work correctly.

Sample output:

account
repository:admin
repository:delete

Credit: answer for GitHub

  • Related