Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

authenticate to bitbucket cloud from a command-line script

Steve Strassmann April 18, 2018

I want to build a command-line script (in bash or python) that reads files from my company's repo (a private repo in Bitbucket Cloud). My script does the equivalent of this:

curl -O https://bitbucket.org/mycompany/myproject/raw/abc123abc456/test.txt

I would like my script to be usable by coworkers (i.e. holders of valid Bitbucket Cloud accounts at mycompany).

I've created an Oauth consumer as described here, but this requires a callback URL, which is not possible for a command-line script. 

I have also tried generating an API token as described here, and passing this as an HTTPDigestAuth password, but that fails (with 401 unauthorized) as well.

How can I generate a token and read from bitbucket cloud without a callback URL?

How should I write a command-line script that generates valid tokens and use them when fetching files from bitbucket cloud?

 

1 answer

0 votes
Néstor Acevedo May 7, 2018

The URL callback is for receive the refresh token via URL parameter, you can put whatever URL.

You will need to refresh the access token each hour so in your script first you should use your OAuth credentials to achieve it via curl.

This curl will return a JSON where is the access token as access_token and then you could use it to read your repository.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events