The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

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

Iván Arias
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!
May 14, 2019

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
jhansoty
June 25, 2019

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
Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2019

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.

danieledraganti
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!
September 28, 2021

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.

TAGS
AUG Leaders

Atlassian Community Events