Not authorized. Please check the properties sonar.login and sonar.password

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Plugin for TFS 2018 from Market place

  • what are you trying to achieve
    I am tying to use the command line scanner for CLI to scan powershell scripts

  • what have you tried so far to achieve this
    I have tried it as a TFS Build script and when that failed I tried it via command line.

I tried it with a sonarqube token and with regular login credential (both mine) and I get the same error.

Here is the command line and associated error, with removed passwords.

E:\Dev>"E:\Dev\AgtProd-manual\_work\_tasks\SonarQubeScannerCli_9f57024b-31f9-4e58-9e39-a47ccc098f03\3.1.0\sonar-scanner\bin\sonar-scanner.bat" -Dsonar.projectKey="PowerShell_Scripts" -Dsonar.projectName="PowerShell_Scripts" -Dsonar.projectVersion="1.0" -Dsonar.host.url="https://sonar.company.com/" -Dsonar.login="abcdef" -Dsonar.login="password" -Dsonar.sources="*" -Dsonar.projectBaseDir="E:\Dev\AgtProd-manual\_work\2\s" -X
14:25:00.440 INFO: Scanner configuration file: E:\Dev\AgtProd-manual\_work\_tasks\SonarQubeScannerCli_9f57024b-31f9-4e58-9e39-a47ccc098f03\3.1.0\sonar-scanner\bin\..\conf\sonar-scanner.properties
14:25:00.440 INFO: Project root configuration file: NONE
14:25:00.471 INFO: SonarQube Scanner 3.0.3.778
14:25:00.471 INFO: Java 1.8.0_231 Oracle Corporation (64-bit)
14:25:00.471 INFO: Windows 10 10.0 amd64
14:25:00.581 DEBUG: keyStore is :
14:25:00.581 DEBUG: keyStore type is : jks
14:25:00.581 DEBUG: keyStore provider is :
14:25:00.581 DEBUG: init keystore
14:25:00.581 DEBUG: init keymanager of type SunX509
14:25:00.784 INFO: User cache: C:\Users\abcdef\.sonar\cache
14:25:00.784 DEBUG: Extract sonar-scanner-api-batch in temp...
14:25:00.800 DEBUG: Get bootstrap index...
14:25:00.800 DEBUG: Download: https://sonar.company.com/batch/index
14:25:01.003 DEBUG: Get bootstrap completed
14:25:01.003 DEBUG: Create isolated classloader...
14:25:01.018 DEBUG: Start temp cleaning...
14:25:01.018 DEBUG: Temp cleaning done
14:25:01.018 DEBUG: Execution getVersion
14:25:01.034 DEBUG: Execution start
14:25:01.190 INFO: Publish mode
14:25:01.253 INFO: Load global settings
14:25:01.331 DEBUG: GET 401 https://sonar.company.com/api/settings/values.protobuf | time=78ms
14:25:01.331 INFO: ------------------------------------------------------------------------
14:25:01.331 INFO: EXECUTION FAILURE
14:25:01.331 INFO: ------------------------------------------------------------------------
14:25:01.331 INFO: Total time: 0.922s
14:25:01.346 INFO: Final Memory: 10M/236M
14:25:01.346 INFO: ------------------------------------------------------------------------
14:25:01.362 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.bootstrap.ScannerPluginInstaller
        at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
        at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
        at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
        at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
        at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
        at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
        at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
        at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
        at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
        at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034)
        at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026)
        at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003)
        at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:134)
        at org.sonar.batch.bootstrapper.Batch.doStart(Batch.java:94)
        at org.sonar.batch.bootstrapper.Batch.start(Batch.java:88)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.start(BatchIsolatedLauncher.java:53)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.start(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:220)
        at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.home.cache.FileCache
        at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
        at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
        at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
        at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
        at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
        at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
        at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
        at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
        at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
        at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
        at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
        at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:62)
        ... 29 more
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.bootstrap.GlobalConfiguration
        at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
        at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
        at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)             at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
        at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
        at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)
        at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)                               at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
        at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
        at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
        at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
        at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
        at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
        at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:62)
        ... 43 more
Caused by: Not authorized. Please check the properties sonar.login and sonar.password.

E:\Dev>

Hi,

your commandline has Scanner version 3.1.0 but log has 3.0.3.778 !?
You didn’t post your Sonarqube version, but i guess your problem is the
use of sonar.login 2x

should be sonar.login and sonar.password instead,
see https://docs.sonarqube.org/latest/analysis/analysis-parameters/

Gilbert

The version of the SonarQube on premise instance is Version 6.7.5 (build 38563).

We are running TFS 2018.

We are using the SonarQube Extension from the Market Place 3.1.0

We have other teams successfully using it, but they are using the Prepare the SonarQube analysis and Complete the SonarQube analysis.

image002.png

I am trying to use the Preform a SonarQube analysis just against code, not part of an actual build.

image003.png

image001.jpg

Not an expert for TFS build engine, we use Azure Devops (TFS before) but only for git management,
Jenkins is our CI server.
Similar to Sonarscanner in Jenkins the credentials have to be configured somehow.
The errormessage directly mentions you need to check the properties sonar.login and sonar.password

I managed to make this work, one of my issues with just trying the command line, I had a typo and was sending the password under sonar.login instead of sonar.password.

I was able to run via command line with username/password combo. I then tried with a Token and it was failing. I created a new SonarQube token and now command line is happy. I must have had a typo.

I created a new Endpoint in TFS for SonarQube with the New Token and now that works as well. We can close the issue as just configuration errors. Thanks for your help.

image001.jpg

:v:
you might tag this as solution for others with a similar problem

Have a nice weekend!

go to sonar-scanar.proprites
and aadd
sonar.login=“admin”
sonae.passwors=“your_password”