pantheon-systems / terminus-build-tools-plugin

Manage multidev environments for a Pantheon site using a GitHub PR workflow.
82 stars 68 forks source link

Bitbucket Client error: for "terminus -v build:env:delete:pr "$TERMINUS_SITE" --yes #479

Closed ozheller-nerd closed 1 year ago

ozheller-nerd commented 1 year ago

Ticket copied from Terminus thread for visibility https://github.com/pantheon-systems/terminus/issues/2345

Internal Pantheon ticket tracking the issue https://getpantheon.atlassian.net/browse/CMS-753

Command Executed "terminus -v build:env:delete:pr "$TERMINUS_SITE" --yes"

Expected behavior I had expected for the command to check the pull requests and if they are merged delete the multi-dev environment from Pantheon.

Actual behavior Getting a client error saying unauthorized even though the token is set as secret

[notice] Call Bitbucket API: GET repositories/{org}/{repo}/pullrequests?state=MERGED%26state%3DDECLINED%26state%3DSUPERSEDED%26state%3DOPEN [error] Client error: GET https://api.bitbucket.org/2.0/repositories/{org}/{repo}/pullrequests?state=MERGED%26state%3DDECLINED%26state%3DSUPERSEDED%26state%3DOPEN resulted in a 401 Unauthorized response

ozheller-nerd commented 1 year ago

Opened per support recommendation.

kporras07 commented 1 year ago

Hi @ozheller-nerd

Could you please make sure you are using an app password that has at least the permissions listed in https://docs.pantheon.io/guides/build-tools/create-project/#access-tokens-optional ?

Screen Shot 2023-05-23 at 15 36 16

If you need to generate a new app password, you can change it under Pipelines -> Repository Variables in your Bitbucket Repository configuration

Please let us know how it goes.

ozheller-nerd commented 1 year ago

I was able to get someone on our team who had access generate a new token. I believe they did BITBUCKET_AUTH=BITBUCKET_USER:APP_PASSWORD for the variable.

It appears to be working now. Thanks. Oz

Oz Heller

Software Engineer

+1 877 664 6373 | nerdery.com | l https://mail.google.com/mail/u/0/goog_592558740inkedin.com https://www.linkedin.com/company/nerdery

NERDERY

A Digital Product Consultancy

On Tue, May 23, 2023 at 4:39 PM Kevin Porras @.***> wrote:

Hi @ozheller-nerd https://github.com/ozheller-nerd

Could you please make sure you are using an app password that has at least the permissions listed in https://docs.pantheon.io/guides/build-tools/create-project/#access-tokens-optional ? [image: Screen Shot 2023-05-23 at 15 36 16] https://user-images.githubusercontent.com/2217820/240424890-6ba2fefd-c266-4623-a002-95e280068772.png

If you need to generate a new app password, you can change it under Pipelines -> Repository Variables in your Bitbucket Repository configuration

Please let us know how it goes.

— Reply to this email directly, view it on GitHub https://github.com/pantheon-systems/terminus-build-tools-plugin/issues/479#issuecomment-1560157369, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW2KAYRLLA3CLSUGTWKE7IDXHUVBVANCNFSM6AAAAAAYMEDO4A . You are receiving this because you were mentioned.Message ID: @.*** .com>

kporras07 commented 1 year ago

Awesome. Thanks for reporting back. I'm closing this issue now. Feel free to reopen if needed

jigarius commented 1 year ago

This seems to be using user account-level App Password. I was wondering if using a repository-level access token would be a better idea. That way, users won't be required to share all project read permission with Terminus by restricting access to per-project tokens.


Screenshot 2023-06-15 at 11 59 51 AM
CourtAvenueKT commented 5 months ago

I was able to get someone on our team who had access generate a new token. I believe they did BITBUCKET_AUTH=BITBUCKET_USER:APP_PASSWORD for the variable. It appears to be working now. Thanks. Oz Oz Heller Software Engineer +1 877 664 6373 | nerdery.com | l https://mail.google.com/mail/u/0/goog_592558740inkedin.com https://www.linkedin.com/company/nerdery NERDERY A Digital Product Consultancy On Tue, May 23, 2023 at 4:39 PM Kevin Porras @.> wrote: Hi @ozheller-nerd https://github.com/ozheller-nerd Could you please make sure you are using an app password that has at least the permissions listed in https://docs.pantheon.io/guides/build-tools/create-project/#access-tokens-optional ? [image: Screen Shot 2023-05-23 at 15 36 16] https://user-images.githubusercontent.com/2217820/240424890-6ba2fefd-c266-4623-a002-95e280068772.png If you need to generate a new app password, you can change it under Pipelines -> Repository Variables in your Bitbucket Repository configuration Please let us know how it goes. — Reply to this email directly, view it on GitHub <#479 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW2KAYRLLA3CLSUGTWKE7IDXHUVBVANCNFSM6AAAAAAYMEDO4A . You are receiving this because you were mentioned.Message ID: @. .com>

I have a question, did you add this as a Bitbucket environment variable?