# You're not authorized to run analysis. No sonar.login or SONAR\_TOKEN env variable was set

**URL:** <https://community.sonarsource.com/t/youre-not-authorized-to-run-analysis-no-sonar-login-or-sonar-token-env-variable-was-set/60391>\
**Category:** SonarQube Cloud\
**Tags:** github, sonarqube-cloud, scanner\
**Created:** [March 23, 2022, 10:31am UTC](https://community.sonarsource.com/t/youre-not-authorized-to-run-analysis-no-sonar-login-or-sonar-token-env-variable-was-set/60391 "2022-03-23T10:31:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![khanh21011999](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/khanh21011999/32/31709_2.png) [@khanh21011999](https://community.sonarsource.com/u/khanh21011999)\
**Post date:** [March 23, 2022, 10:31am UTC](https://community.sonarsource.com/t/youre-not-authorized-to-run-analysis-no-sonar-login-or-sonar-token-env-variable-was-set/60391/1 "2022-03-23T10:31:56Z")

</div>

I’m trying to add my github project to sonarclound, i do all the require step like add new organization, add project and when in the step configure project i get stuck, i do the exactly every step but it still can’t not configure:  
I add the SONAR\_TOKEN:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/f/b/fb5d0ce4ea288eb0cc53158067d6b71d0fcb4acd.png)  
i add the SONAR\_TOKEN to build.yml file:  
 ![Screen Shot 2022-03-23 at 17.27.27](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/b/0/b00141d61d7475f59ce44d2e124e96aba14a39aa.png)  
I added required sonar-project.properties  
 ![Screen Shot 2022-03-23 at 17.28.55](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/e/5/e55131672ac9aed489da6b258fb72840f873e6ce.png)

But it won’t work, so i use the cli, using this function to add the scanner:

```auto
export SONAR_SCANNER_VERSION=4.7.0.2747
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"

```

Use this to add to current project:

```auto
sonar-scanner \
  -Dsonar.organization=khanh21011999 \
  -Dsonar.projectKey=khanh21011999_testUnitTest \
  -Dsonar.sources=. \
  -Dsonar.host.url=https://sonarcloud.io

```

But it return this in the terminal

````auto

ERROR: You're not authorized to run analysis. No sonar.login or SONAR_TOKEN env variable was set

ERROR:

ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.```

Please help, what did i do wrong?
````

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [March 23, 2022, 9:47pm UTC](https://community.sonarsource.com/t/youre-not-authorized-to-run-analysis-no-sonar-login-or-sonar-token-env-variable-was-set/60391/2 "2022-03-23T21:47:03Z")

</div>

Hey there.

Checking your GitHub repository, it looks like your GitHub Actions _build.yml_ file has been consistently malformed. I would recommend copying what’s in the SonarCloud UI tutorial _exactly_ (except changing the branch name from `master` to `main`).

You run into this issue locally as you haven’t passed `sonar.login` or set the `SONAR_LOGIN` environment variable (`export SONAR_TOKEN=`)

---

<div class="post-metadata">

**Author:** ![khanh21011999](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/khanh21011999/32/31709_2.png) [@khanh21011999](https://community.sonarsource.com/u/khanh21011999)\
**Post date:** [March 24, 2022, 2:33am UTC](https://community.sonarsource.com/t/youre-not-authorized-to-run-analysis-no-sonar-login-or-sonar-token-env-variable-was-set/60391/3 "2022-03-24T02:33:59Z")

</div>

Hi Colin, i will try again and report you, thank for your answer

---

<div class="post-metadata">

**Author:** ![khanh21011999](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/khanh21011999/32/31709_2.png) [@khanh21011999](https://community.sonarsource.com/u/khanh21011999)\
**Post date:** [March 29, 2022, 6:49pm UTC](https://community.sonarsource.com/t/youre-not-authorized-to-run-analysis-no-sonar-login-or-sonar-token-env-variable-was-set/60391/4 "2022-03-29T18:49:13Z")

</div>

Hi Colin, somehow it lead to this problem after i successful make it work as you said ( thank you again Colin) , please help :((

> [@A few extra steps are needed for SonarCloud to analyze your code coverage](https://community.sonarsource.com/t/a-few-extra-steps-are-needed-for-sonarcloud-to-analyze-your-code-coverage/60730):
>
> I’m trying to setup code coverage on sonarcloud, I followed every step in here But somehow, in action of github, it show correct But in the sonarCloud, it remain the same message “A few extra steps are needed for SonarCloud to analyze your code coverage” My sonarcloud.properties: sonar.organization=khanh21011999 This is the name and version displayed in the SonarCloud UI. sonar.projectName=testUnitTest sonar.projectVersion=1.0 Path is relat…
