Error: Unauthorized: Access is denied due to invalid credentials

Hi,

I already had created a project in SonarQube and the project was linked to a project hosted on github.
Everything was working fine until I deleted the project from the SonarQube and re-created it. I also adjusted the new project key in the github workflow.
Now when the CI triggers, the following error happens:

2023-11-09T11:54:35.3046984Z ##[group]Run .\.sonar\scanner\dotnet-sonarscanner begin /k:"MyProject_AYuz6t9tvpT26pQ3-wHv" /d:sonar.token="***" /d:sonar.host.url="***" /d:"sonar.verbose=true" /d:"sonar.cs.opencover.reportsPaths=**/*.opencover.xml" /d:"sonar.sarifReportPaths=D:\a\my-project\my-project\report.sarif" /v:"116/merge"
2023-11-09T11:54:35.3052903Z e[36;1m.\.sonar\scanner\dotnet-sonarscanner begin /k:"MyProject_AYuz6t9tvpT26pQ3-wHv" /d:sonar.token="***" /d:sonar.host.url="***" /d:"sonar.verbose=true" /d:"sonar.cs.opencover.reportsPaths=**/*.opencover.xml" /d:"sonar.sarifReportPaths=D:\a\my-project\my-project\report.sarif" /v:"116/merge"e[0m
2023-11-09T11:54:35.3055717Z e[36;1mdotnet build MyProject.slne[0m
2023-11-09T11:54:35.3056979Z e[36;1m.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="***"e[0m
2023-11-09T11:54:35.3109755Z shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
2023-11-09T11:54:35.3110537Z env:
2023-11-09T11:54:35.3111010Z   sonar-scanner-version: 5.13
2023-11-09T11:54:35.3111793Z   JAVA_HOME: C:\hostedtoolcache\windows\Java_Microsoft_jdk\11.0.19\x64
2023-11-09T11:54:35.3112912Z   JAVA_HOME_11_X64: C:\hostedtoolcache\windows\Java_Microsoft_jdk\11.0.19\x64
2023-11-09T11:54:35.3113813Z   DOTNET_ROOT: C:\Program Files\dotnet
2023-11-09T11:54:35.3114766Z   GITHUB_TOKEN: ***
2023-11-09T11:54:35.3115182Z ##[endgroup]
2023-11-09T11:54:35.7553101Z SonarScanner for MSBuild 5.13
2023-11-09T11:54:35.7555968Z Using the .NET Core version of the Scanner for MSBuild
2023-11-09T11:54:35.8801355Z Default properties file was found at D:\a\my-project\my-project\.sonar\scanner\.store\dotnet-sonarscanner\5.13.0\dotnet-sonarscanner\5.13.0\tools\net5.0\any\SonarQube.Analysis.xml
2023-11-09T11:54:35.8805448Z Loading analysis properties from D:\a\my-project\my-project\.sonar\scanner\.store\dotnet-sonarscanner\5.13.0\dotnet-sonarscanner\5.13.0\tools\net5.0\any\SonarQube.Analysis.xml
2023-11-09T11:54:35.8807935Z sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2023-11-09T11:54:35.8809490Z Pre-processing started.
2023-11-09T11:54:35.8826331Z Preparing working directories...
2023-11-09T11:54:35.8836464Z Using environment variables to determine the download directory...
2023-11-09T11:54:35.9016984Z 11:54:35.901  11:54:35.892  Loading analysis properties from D:\a\my-project\my-project\.sonar\scanner\.store\dotnet-sonarscanner\5.13.0\dotnet-sonarscanner\5.13.0\tools\net5.0\any\SonarQube.Analysis.xml
2023-11-09T11:54:35.9020539Z 11:54:35.901  11:54:35.901  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2023-11-09T11:54:35.9120240Z 11:54:35.911  Updating build integration targets...
2023-11-09T11:54:35.9196458Z 11:54:35.918  Installed SonarQube.Integration.ImportBefore.targets to C:\Users\runneradmin\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
2023-11-09T11:54:35.9206215Z 11:54:35.92  Installed SonarQube.Integration.ImportBefore.targets to C:\Users\runneradmin\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
2023-11-09T11:54:35.9222261Z 11:54:35.921  Installed SonarQube.Integration.ImportBefore.targets to C:\Users\runneradmin\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
2023-11-09T11:54:35.9235296Z 11:54:35.923  Installed SonarQube.Integration.ImportBefore.targets to C:\Users\runneradmin\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
2023-11-09T11:54:35.9249414Z 11:54:35.924  Installed SonarQube.Integration.ImportBefore.targets to C:\Users\runneradmin\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
2023-11-09T11:54:35.9270909Z 11:54:35.926  Installed SonarQube.Integration.ImportBefore.targets to C:\Users\runneradmin\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
2023-11-09T11:54:35.9287292Z 11:54:35.928  Installed SonarQube.Integration.ImportBefore.targets to C:\Users\runneradmin\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
2023-11-09T11:54:35.9297906Z 11:54:35.929  Installed SonarQube.Integration.targets to D:\a\my-project\my-project\.sonarqube\bin\targets
2023-11-09T11:54:35.9305083Z 11:54:35.93  Creating config and output folders...
2023-11-09T11:54:35.9311600Z 11:54:35.931  Creating directory: D:\a\my-project\my-project\.sonarqube\conf
2023-11-09T11:54:35.9313276Z 11:54:35.931  Creating directory: D:\a\my-project\my-project\.sonarqube\out
2023-11-09T11:54:35.9538181Z 11:54:35.953  Fetching server version...
2023-11-09T11:54:35.9559030Z 11:54:35.955  Downloading from ***/api/server/version...
2023-11-09T11:54:36.8062454Z 11:54:36.805  Response received from ***/api/server/version...
2023-11-09T11:54:36.8151313Z 11:54:36.814  Checking validity of server license
2023-11-09T11:54:36.8156675Z 11:54:36.815  Downloading from ***/api/editions/is_valid_license...
2023-11-09T11:54:36.9804190Z 11:54:36.98  Response received from ***/api/editions/is_valid_license...
2023-11-09T11:54:36.9855756Z 11:54:36.985  Unauthorized: Access is denied due to invalid credentials. Please check the authentication parameters.
2023-11-09T11:54:36.9894668Z 11:54:36.989  Pre-processing failed. Exit code: 1
2023-11-09T11:54:37.2577021Z MSBuild version 17.7.3+4fca21998 for .NET
2023-11-09T11:54:39.1613606Z   Determining projects to restore...
2023-11-09T11:55:33.9354265Z   Restored D:\a\my-project\my-project\my-project.csproj (in 54.14 sec).
2023-11-09T11:55:46.0103041Z   my-project -> D:\a\my-project\my-project\bin\Debug\net6.0\my-project.dll
2023-11-09T11:55:47.3488907Z   The package my-project.1.1.0 is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important.
2023-11-09T11:55:47.3625035Z   Successfully created package 'D:\a\my-project\my-project\bin\Debug\my-project.1.1.0.nupkg'.
2023-11-09T11:55:48.7312940Z 
2023-11-09T11:55:48.7324681Z Build succeeded.
2023-11-09T11:55:48.7325735Z     0 Warning(s)
2023-11-09T11:55:48.7326533Z     0 Error(s)
2023-11-09T11:55:48.7327109Z 
2023-11-09T11:55:48.7328530Z Time Elapsed 00:01:11.23
2023-11-09T11:55:50.5765900Z SonarScanner for MSBuild 5.13
2023-11-09T11:55:50.5890297Z Using the .NET Core version of the Scanner for MSBuild
2023-11-09T11:55:50.6975834Z 11:55:50.694  SonarQube analysis could not be completed because the analysis configuration file could not be found: D:\a\my-project\my-project\.sonarqube\conf\SonarQubeAnalysisConfig.xml.

Hey there.

If you were using a project analysis token, then deleting the project would have deleted the token. You should generate a new token (either project-specific, or a global analysis token) and replace it in your pipeline.

We use a global token.

Thanks.

Where you are including the token? I don’t see it in your environment variables (like SONAR_TOKEN)