Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Pipe "Trigger pipeline 0.3.0" is using wrong account for Auth

Edited

Hi,

I'm trying to run, from my pipeline, a pipeline from other repo using the pipe "Trigger pipeline 0.3.0".
Both repositories belongs to a Team.
The pipe requires an app password which can not be generated for the team, so I've generated it in my own account with ALL the permissions checked (just for testing).

When I try to run the pipe I always get the following error:

DEBUG: https://api.bitbucket.org:443 "POST /2.0/repositories/TEAM/REPO/pipelines/ HTTP/1.1" 401 0
✖ API request failed with status 401. Check your account and app password and try again.

If I change the "account" parameter and set my user I have the same error:

DEBUG: https://api.bitbucket.org:443 "POST /2.0/repositories/MY_USER/REPO/pipelines/ HTTP/1.1" 401 0
✖ API request failed with status 401. Check your account and app password and try again.

I think it is maybe not using the right user for login.

Anyway, I think it would be better to use OAuth credentials over App passwords so it could be run over the team account and not in my personal one.

I've tried this from command line, with OAuth credentials for the Team account, and it seems to work properly:

apt update && apt -y install jq

ACCESS_TOKEN=$(curl -s -X POST -u "$BITBUCKET_OAUTH_KEY:$BITBUCKET_OAUTH_SECRET" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials | jq -r ".access_token")

curl -X POST -is -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/TEAM/REPO/pipelines/ -d '
{
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "master"
}
}'

2 answers

I was able to run trigger-pipeline:3.0.0 with an individual account. This has different options than the 0.3.0 version you are using so maybe just moving to the latest may resolve your problem. 

https://bitbucket.org/atlassian/trigger-pipeline/src/master/

+1 for the experiment with OAuth for the team account.

0 votes

Hi @Iván Arias , thanks for your research and suggestion. We're currently considering adding support for using OAuth credentials in the pipe. So chances are that upcoming version will have it.

Hello Alexander, I am having the same issue (error 401) on trigger-pipeline:4.2.1, using OAuth credentials. Does it work now by any chance?

Thank you in advance.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

221 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you