Project import unable to link a project due to "Authentication is required"

I am no longer able to link any Bitbucket Cloud repository to its SonarCloud counterpart. I was able to link a few then it stopped working where the login button briefly presents a popup that goes away and shows the same SonarCloud settings screen with a login button. Initially used Safari, then switched to Firefox once the error appeared, but unable to get past it.

The browsers console shows lots of Content Security Policy warnings and this error Content Security Policy: The page’s settings observed the loading of a resource at https://api.atlassian.com/flags/api/v1/frontend/featureFlagValues (“connect-src”). A CSP report is being sent.

  • SonarCloud
  • XHR GET https://sonarcloud.io/api/projects/search_my_projects?ps=500
    [HTTP/1.1 401 117ms]
    Response
    JSON
    errors [ {…} ]
    0 Object { msg: “Authentication is required” }
    msg “Authentication is required”
  • Bitbucket Cloud > [any repository] > Repository settings > SonarCloud settings > Login with Bitbucket
  • No workaround

Same as this issue: Unable to setup bitbucket widget

Hello Orlando,

And welcome to the community!

If I understand correctly you are trying to bind projects that already exists in SonarCloud to their Bitbucket repositories ?

Because if the projects don’t exists yet in SonarCloud then you should use the SonarCloud UI to import them directly. It might be a workaround while we investigate the issue with the Bitbucket Cloud integration.

Hi Gregiore, thanks!

Yes, the projects in SonarCloud were created using the sonar-scanner plugin in Maven. The settings file has the org and token, a parent POM has the plugin definition, and each project POM an scm section.

The Bitbucket Cloud repos do not show any integration and require an import.

There are other issues in Bitbucket Cloud that are perhaps for another topic. e.g. the projects that are connected show the widget, but only display metrics (and navigate to) the main branch regardless of the branch selected in the Bitbucket Cloud. The same is true for pull requests.