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:
<span>DEBUG: <a href="https://api.bitbucket.org:443" target="_blank" rel="noopener nofollow noreferrer">https://api.bitbucket.org:443</a> "POST /2.0/repositories/<em>TEAM</em>/<em>REPO</em>/pipelines/ HTTP/1.1" 401 0</span><span><br>✖ API request failed with status 401. Check your account and app password and try again.</span>
If I change the "account" parameter and set my user I have the same error:
<span>DEBUG: <a href="https://api.bitbucket.org:443" target="_blank" rel="noopener nofollow noreferrer">https://api.bitbucket.org:443</a> "POST /2.0/repositories/<em>MY_USER</em>/<em>REPO</em>/pipelines/ HTTP/1.1" 401 0</span><span><br>✖ API request failed with status 401. Check your account and app password and try again.</span>
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"
}
}'