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,466,100
Community Members
 
Community Events
176
Community Groups

App password not working on uploading download artifact

Hi --

I have a 50meg windows installer for my product, that sits in the Downloads page of my project. I think this is what Bitbucket calls a "download artifact". Last year -- before Bitbucket started requiring app passwords -- I had no trouble uploading the installer to my Downloads page (I used Insomnia to send the HTML post),

After Bitbucket switched to app passwords, I generated an app password for my project and am able to git my code up/down from the server. But the upload of the download artifact fails. In an effort to solve that, I gave up on Insomnia and wrote a python script. Here's the script:

import requests

#url = 'http://httpbin.org/post'
url = 'https://api.bitbucket.org/2.0/repositories/alcramer/comiola/downloads'

headers = {
"Authorization": "Bearer MY_APP_PASSWORD"
}

files = {'file': open('test.txt', 'rb')}

r = requests.post(url, headers=headers, files=files)
print(r.text)

Bitbucket gives this response:

{"type": "error", "error": {"message": "Access token expired."}}

 

How do I fix this?

 

Thanks!

Al Cramer

1 answer

1 accepted

0 votes
Answer accepted

I fixed my problem. When you open an account on Bitbucket, it asks that you enter a "Name" (I entered "Al Cramer", as that happens to be my name). When it creates depositories, it mangles the string you entered to create a string that they call your "username" (mangling seems to be: convert to lower case and kill spaces). That mangled string is the one that's used to create paths. 

BUT it's also the  string you need to specify as user if you do an HTTP POST.  This curl upload command fails:

curl -v -u "Al Cramer:MY_APP_PASSWORD" -X POST https://api.bitbucket.org/2.0/repositories/alcramer/comiola/downloads -F files=@test.txt

But this upload works:

curl -v -u "alcramer:MY_APP_PASSWORD" -X POST https://api.bitbucket.org/2.0/repositories/alcramer/comiola/downloads -F files=@test.txt

I leave it to minds more powerful than mine to consider Bitbucket's handling of "Name" vs "username", and how that impacted on their decision to switch from email addresses to mangled names on file uploads of depository artifacts. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events