Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use the API to update a snippet with app passwords?

sorcerykid
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 17, 2020

I created an App password according to these directions.

https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html

I have also followed the documentation for updating snippets using my App password for the credentials.

https://developer.atlassian.com/bitbucket/api/2/reference/resource/snippets#post

For some reason I always get a 403 "This endpoint does not support token-based authentication" error.  Yet I can create snippets just fine by authenticating with the App password mechanism. So why can I not update snippets the exact same way?

I can't find anything in the document for App passwords that says  that they only work for certain endpoints of the API. In fact, it very specifically suggests it should work within the scope of the entire API.

1 answer

0 votes
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 17, 2020

Hello @sorcerykid,

Thanks for reaching out and welcome to the Community!

The endpoint you linked is to create a snippet, the one to update a snippet is this: /2.0/snippets/{workspace}/{encoded_id} However, I believe you actually tried the right one, just mentioned the wrong link.

What I think you faced is the wrong example in the PUT endpoint description: the method there is specified as POST whereas it should be PUT. I just confirmed this works for me:

curl -X PUT -u dpenkin:<app_password> -H "Content-Type: application/json" https://api.bitbucket.org/2.0/snippets/dpenkin/n79pb6 -d '{"title": "New snippet title"}'

If I use POST, I get the same error you mentioned (which also looks confusing, but that's a separate task for me to look into).

So I believe you just need to change POST to PUT, and it'll work.

Hope this helps. Let me know that worked.

Cheers,
Daniil

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events