How can I enable force authentication in sonarqube instance using api

Hello Team,
I want to enable the force authentication via Ansible script. Can u tell me how can I set the sonar.forceauthentication=true
I need to run the Ansible on more then 60 instances.

I tried the following but it doesn’t enable the force userauthentication.

Url: “{{sonar_url}}/api/settings/set”
method: POST
body: “key=sonar.forceAuthnetication&value=true”
force_basic_auth: yes
user: admin
password: admin
validate_certs: no

Can you tell me how can I pass the authorization header in this case?its telling me unauthorized error for this task
Sonarversion 6.7.3 is being used by us


Hi Yash,

I’ve no idea how is working Ansible, the only thing I can tell you is that the correct setting is “sonar.forceAuthentication” and not sonar.forceAuthnetication.

Julien Lancelot

7 posts were split to a new topic: How can I remove the see source code and browse permission for sonar-users?

Hello @julienlancelot, I was able to set the forceAuthentiation via the Api.
Thank you for your help it was the typo on my side.


1 Like