Skip to content
Latchkey

SonarQube "You're not authorized to run analysis" in CI

The scanner authenticated to SonarQube but the token it used is not allowed to run analysis on this project. Either no token was supplied, it is wrong, or its user lacks the "Execute Analysis" permission.

What this error means

The scanner aborts with "You're not authorized to run analysis. Please contact the project administrator." or "Not authorized. Please check the property sonar.token."

SonarQube
ERROR: You're not authorized to run analysis. Please contact the project administrator.

Common causes

Missing or invalid SONAR_TOKEN

The SONAR_TOKEN env var was not set from a secret, expired, or was revoked, so the scanner runs unauthenticated or with a dead token.

The token user lacks Execute Analysis permission

The token authenticates but its user does not have the "Execute Analysis" permission on the project, which is required to push analysis results.

How to fix it

Provide a valid token via secret

  1. Generate a token in SonarQube/SonarCloud under your account security settings.
  2. Store it as the SONAR_TOKEN repository secret.
  3. Expose it to the scan step's environment.
.github/workflows/ci.yml
- uses: sonarsource/sonarqube-scan-action@v4
  env:
    SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
    SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

Grant Execute Analysis to the token user

In Project Settings, Permissions, give the token's user (or a group it belongs to) the "Execute Analysis" permission.

How to prevent it

  • Keep SONAR_TOKEN in CI secrets and rotate it before expiry.
  • Use a dedicated CI user that has Execute Analysis on the project.
  • Avoid embedding tokens in committed config files.

Frequently asked questions

What causes ""not authorized to run analysis""?
The SONAR_TOKEN env var was not set from a secret, expired, or was revoked, so the scanner runs unauthenticated or with a dead token.
How do I fix "not authorized to run analysis"?
Provide a valid token via secret

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card