Bitbucket - Invalid personal access token

I’m trying to set up Bitbucket integration with SonarQube version 8.9.6 (community edition).
I generated the personal access token on bitbucket and pasted it into the form in SonarQube but it fails with “Invalid personal access token”. Is there a way to get more info on why it is considered invalid?

Hi,

Welcome to the community!

What do your server logs say?

 
Ann

I already looked in the logs but couldn’t find this error message there. I can’t find anything with a case-insensitive search for “token”. There are results for “bitbucket” but those also seem to be irrelevant.

Hi,

You might try temporarily bumping your server logging up to TRACE (I believe that’s the level that’s needed), and seeing what you get. Note that the logs get big fast at this level, so you’ll want to turn it back down as soon as you’ve run the test.

I suspect we’ll find that this message originates with Bitbucket, rather than SonarQube, but let’s see if we can get anything else out of the logs.

 
Ann

Thanks for the tip, after changing the log level to TRACE I can find the part where the web server tries to contact bitbucket. It says “Unable to contact Bitbucket server: 401”.
Is there a way to make it use SPNEGO while connecting?

Hi,

I’m not aware of anything like that. But since the 401 is coming from Bitbucket, wouldn’t this just be about fixing the BB token you’re using to connect?

 
Ann

I don’t think the token needs “fixing”, as I mentioned in the initial message I copied it directly from BitBucket. Also the error page that appears in the logs is the exact same that I get when trying to fetch a page from it without SPNEGO, such as by using curl from the command line. In that case the solution would be adding --negotiate -u : to the command.