Hi Dennis, cloning with OAuth looks like:
$ git clone https://x-token-auth:{access_token}@bitbucket.org/user/repo.git
The string x-token-auth
is required as a substitute for the username.
OAuth needs a key and secret, which together are know as an OAuth consumer. To create a consumer, do the following:
In the left navigation panel, click OAuth > Add consumer.
The system will ask you for name, description, callback URL and URL.
Let us know if you have any more questions or if you're stuck somewhere.
Best regards,
Ana
what should we do with that Key and Secret then ? in the URL you are talking about access_token and then you are giving us Key and Secret ?
The best would be if you can make a example URL of how it looks like
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An excessive incomplete @Ana Retamal's answer.
The OAuth credentials are easy to create, but the auth_token is what you have never touched.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Amir Koklanfor generating the token you can use your consumer key as key in the following address:
https://bitbucket.org/site/oauth2/authorize?client_id={key}&response_type=token
It will ask you for permissions according what you have chosen on creating the consumer.
In the URL you will find the access token that you can use later in
git clone https://x-token-auth:{access_token}@bitbucket.org/user/repo.git
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please explain how to access that URL? I am new to this and I am trying to build a script that declines a PR but I need the OAuth. I have the key and secret how to I use that URL to get the token?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is mandatory to create the OAuth2 credentials accessing to your accout.
Follow the steps in https://community.atlassian.com/t5/Bitbucket-questions/Re-hot-to-git-clone-with-oauth-how-to-create-token-for/qaq-p/697127/comment-id/21947#M21947
The callback URL can be any URL; you can use http://example.com.
When you call https://bitbucket.org/site/oauth2/authorize?client_id={key}&response_type=token (the key value for client_id is your OAuth consumer key), you will find the callback url with the params sent by BitBucket. One of these params is the access token.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for all your support. Here is a step by step description of the process which worked for me.
I just copied and pasted a selection of all the steps mentioned above (also from other threads) and tried to make a recipe.
# How to generate/use bitbucket API key
first go to https://bitbucket.org/account/user/HoChiMinh/api and create a
new consumer (you can use https://example.com as callBackUrl if necessary).
OAuth needs a key and secret, which together are know as an OAuth consumer. To create a consumer, do the following:
1. In your Bitbucket account, navigate to your avatar in the bottom left and click Bitbucket settings.
2. In the left navigation panel, click OAuth > Add consumer.
3. The system will ask you for name, description, callback URL and URL.
4. Click Save. The system generates a key and a secret for you.
Toggle the consumer name to see the generated Key and Secret value for your consumer.
then:
```
> request:
curl -X POST -u "$key:$secret" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials
> reponse:
{"access_token": "$APIKEY", "scopes": "snippet issue team pullrequest project wiki pipeline webhook", "expires_in": 7200, "refresh_token": "$REFRESH_TOKEN", "token_type": "bearer"}
> test:
git clone "https://x-token-auth:$APIKEY@bitbucket.org/$user/$repo"
```
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I know this is a fairly old thread, but, just in case, I wrote my own credential store to manage bitbucket's token:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.