Title
#general
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 12:45 PM
Hey folks. IDK if this is the right place, but I am facing an issue related to integrating Infracost into my CI/CD Pipelines on Bitbucket. I am receiving an error related to:
Error: Error creating comment: 401 Unauthorized
I’ve searched on github issues, but only found some information related to emojis comments that seems to be fixed already. My token has full access scope. Do you have any hints on that? Regards…
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 12:53 PM
Hi Pietro! 👋 Let's see...
12:54 PM
Do you use Bitbucket Cloud or Server version?
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 12:56 PM
Bitbucket Cloud
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 12:57 PM
May I also ask if you can copy/paste the
infracost comment
command you used (removing the sensitive info)?
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 12:59 PM
infracost comment bitbucket --path=infracost.json \     
--repo=$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG \
--pull-request=$BITBUCKET_PR_ID \                                        --bitbucket-token=$BITBUCKET_TOKEN \                                       --behavior=update
12:59 PM
Already teste with --behaviour=new/delete-and-new/update
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 1:00 PM
Could you try to change
--bitbucket-token
value to
<your username>:$BITBUCKET_TOKEN
? BB Cloud needs this format for some reason
1:01 PM
I guess we need to update our docs to use this format, we only mention this detail in the flag description https://www.infracost.io/docs/features/cli_commands/#bitbucket
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 1:01 PM
--bitbucket-token=pietro.dellamore:TOKEN
1:01 PM
like this?
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 1:01 PM
Yep
1:04 PM
The reason why it needs to be done this way is that we use their API to post comments and apparently their API uses basic auth in format "username😛assword", where token is the password in this case https://developer.atlassian.com/cloud/bitbucket/rest/intro/?utm_source=%2Fbitbucket%2Fapi%2F2%2Freference%2Fmeta%2Fauthentication&amp;utm_medium=302#authentication
1:22 PM
Any luck?
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 1:26 PM
Not yet :c
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 1:26 PM
Still 401?
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 1:27 PM
Yes, but I feel that I am doing something wrong
1:27 PM
IDK if this is because we use Okta as IdP for Bitbucket…
1:27 PM
Maybe this have a relation
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 1:27 PM
Hm, how have you generated the token?
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 1:28 PM
Using app passwords on bitbucket cloud
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 1:29 PM
Yeah, I used the same 🤔
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 1:31 PM
I believe that my username is my e-mail address
1:31 PM
I saw somewhere, that this might be a problem, I just don’t remember where I saw it
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 1:32 PM
Can you try with email maybe? 😃
Ali (Infracost)

Ali (Infracost)

06/15/2022, 1:40 PM
There’s a curl to test the bitbucket authentication if that helps: https://github.com/infracost/infracost/issues/1693
Pietro Dell'Amore

Pietro Dell'Amore

06/15/2022, 1:49 PM
I’ll try later and update it here
1:49 PM
Thanks so much until now for all the effort
Vadim (Infracost)

Vadim (Infracost)

06/15/2022, 1:50 PM
Good luck, hope it works 🙂
10:53 AM
Hi Pietro! Just checking in if you had a chance to try it
Pietro Dell'Amore

Pietro Dell'Amore

06/20/2022, 5:22 PM
Hi @Vadim (Infracost) sorry for the delayed response, it was holiday here in Brazil.
5:22 PM
It does work with username:token! Thank you so much for the effort and support ❤️
Vadim (Infracost)

Vadim (Infracost)

06/20/2022, 5:22 PM
Hey! No worries! Hope you had a great time 😃
5:22 PM
Glad to hear it! 😃
Ali (Infracost)

Ali (Infracost)

06/20/2022, 5:28 PM
@Vadim (Infracost) Should I update the bitbucket pipeline readme to mention this? I can also add a troubleshooting section to that with the 401 error (similar to what we do for gitlab). Any other action items for me?
Vadim (Infracost)

Vadim (Infracost)

06/20/2022, 5:30 PM
@Ali (Infracost) We mentioned in CLI commands section in our docs, but yeah, would be great to have it there https://www.infracost.io/docs/features/cli_commands/#bitbucket. Thank you!
Ali (Infracost)

Ali (Infracost)

06/20/2022, 5:31 PM
thanks - will do!
Pietro Dell'Amore

Pietro Dell'Amore

06/20/2022, 5:33 PM
I tried to open a PR adding this on the README.md but I do not have enough permissions to do it… :c
Ali (Infracost)

Ali (Infracost)

06/20/2022, 5:36 PM
That would be much appreciated! ah you should be able to fork the repo, then send a PR from your fork to our repo. I’ll try and get to this later this week if you’re busy though
5:43 PM
I am running out of time now, if you have too many changes to request, I can do it later. Tks
Ali (Infracost)

Ali (Infracost)

06/20/2022, 5:45 PM
Thank you! I merged it as it’s better than what we have and helps other users 🙂 Later this week I’ll tidy-up and add a troubleshooting section like we have for gitlab
Pietro Dell'Amore

Pietro Dell'Amore

06/20/2022, 5:45 PM
Nice! ❤️