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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,622
Community Members
 
Community Events
185
Community Groups

Python OAuth2 Token - using App key

Hi, I'm wondering if anyone has managed to get OAuth tokens working with App keys (I believe user passwords are now allowed now as that would be Resource Owner Password Credentials Grant (4.3) which is no longer supported). ref: https://developer.atlassian.com/cloud/bitbucket/oauth-2/

I've been trying the below (and modifications of it) but I just can't seem to get it to work. Are app-key O-auth supported? 

Alternatively, how else do I have a python script get a token?

```

    import requests
    client_id = 'my-user-name'
    client_secret = 'my-app-key'

    data = { 'grant_type': 'client_credentials'}
    response = requests.request(
        "POST",
        url,
        auth=(client_id, client_secret),
        data=data
    )

    print(response.json())
    try:
        access_token = response.json()['access_token']
        print(f"access_token: {access_token}")
    except:
        print("OAuth Failed")
        sys.exit(-1)
```
I also had a look at https://bitbucket.org/atlassian/bb-cloud-client-creds-grant-sample-app/src/master/ and it says a client-id is "Key generated from Bitbucket Settings → Add Consumer", but I can't see consumer settings anywhere... This repository is lined from the oauth-2 page, but hasn't been updated since 2018, so I assume the UI has changed and so the settings don't exist any more?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 02, 2022

Hi Richard,

When you say app key, do you mean an app password generated by going to your avatar > Personal settings > App passwords?

I see that you are passing this for the client's secret (client_secret = 'my-app-key') and that you are using username for the client_id, but I think these need to be the key and secret of the OAuth consumer (the Key for client_id and the Secret for client_secret).

OAuth consumers are now associated with workspaces. In order to find the key and secret, you can go to your avatar > All workspaces > select the workspace you generated the OAuth consumer for > Settings > OAuth consumers > select the consumer and you'll see both the key and secret.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events