What is http header for API authentication?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube 8.5)
  • what are you trying to achieve (HTTP header name for authetication token)

I want to call Web API from my client application. Documentation says The token is sent via the login field of HTTP basic authentication, without any password
shows example using curl

curl -u THIS_IS_MY_TOKEN: https://sonarqube.com/api/user_tokens/search

This works using curl, which is just for testing purpose.

However I want to know the HTTP Header Name for authentication that i need to include in HTTP request when my client application is making api call?

Hi @LP2020 ,

there is no magic involved here. we are using http basic auth as defined in RFC7617. Depending on the Language that you are using you can just create a basic authentication with an empty password field and fire at will.

Here is an example in Python:

import requests
from requests.auth import HTTPBasicAuth

TOKEN = "THIS_IS_MY_TOKEN"
req = requests.get('https://sonarqube.your.company.com/api/system/health', auth=HTTPBasicAuth(TOKEN, ""))
print(req.json())

hope that helps

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.