Authorization Error when Running SonarScanner

I am running sonar scanner scan from GCP Cloudbuilds.
One day suddenly got a permission issue without making any changes
when I ran the analysis I was stuck at the error saying “**ERROR: You’re not authorized to run analysis.
DEBUG: POST 403 Code Quality Tool & Secure Analysis with SonarQube | time=64ms
Step #0 - “Sonarqube Quality Check”: 10:07:05.306 DEBUG: stylelint-bridge server will shutdown

ERROR: build step 0 “us-central1-docker.pkg.xxxx/xxxx/xxxx/sonar-scanner” failed: step exited with non-zero status: 2"

Command used to run the analysis :

  • id: “Sonarqube Quality Check”
    name: “xxxx/sonar-scanner”
    • “”
    • “-Dsonar.login=xxxxx”
    • “-Dsonar.projectKey=xxxxx”
    • “-Dsonar.sources=.”
      I tried multiple options as below for this error and was not able to resolve

I’ve tried giving all the permissions to run the analysis in the sonarqube and Still had no luck. Please suggest how to overcome this error and run the analysis successfully.

Hey there.

I’m a bit confused. You mention SonarQube (and link to it) but then you say you adjusted permissions in SonarCloud (in a settings window only available in SonarCloud). Which are you using?

Using SonarQube, I mentioned the permissions which I shared below


Have you tried regenerating a new user token for your account and using that in your build?

Yes, I have regenerated the key and tried still have the same issue.


Does this project key match the expected project key on the server? One issue can be that a new project key is being targeted (or the project key changed server-side), and the user doesn’t have access to Create projects.