You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
i am trying to create a java application for sending files to bitbucket using atlasian cloud rest-api's provided by atlasian. My goal here is to send files to bitbucket account without logging in to bitbucket account. the official document says that generate token and use it but its too confusing, coz we can generate many types of token in bitbucket account, please tell me how to create a access token and how to use it to access workspaces and repositories for sending files to workpaces or repositories, thanks in advance
Hello @srinath reddy ,
Thank you for reaching out to Atlassian Community!
You can use an OAuth consumer in order to generate an access token that can then be used to authenticate calls to Bitbucket Cloud Public API. Let me share below the steps for using OAuth client credential flow:
curl -X POST -u "Key:Secret" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials
Please note that access tokens expire in 2 hours, and you will need to call the endpoint above again to generate a new access token.
curl -X POST https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/src \
--header 'Authorization: Bearer <Access Token>' -F path/within/repo/myfile.txt=@file_to_upload.txt
This will create a new commit on the main branch adding a file named myfile.txt inside the path/within/repo directory of your repository.
For more details on authentication methods and available endpoints, you're also welcome to check Bitbucket Cloud public API reference.
Alternatively, we have recently released Repository Access Tokens (RATs) in Bitbucket Cloud that can also be used to authenticate API calls. In case would to learn more about RATs, and how to create and use them, I would recommend taking a look at our Repository Access Tokens documentation.
Hope that helps! Let me know if you have any questions.
Thank you, @srinath reddy !
Patrik S
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.