API user token does not work


I am trying to explore web-api in our SonarQube Developer Edition Version 9.9 (build 65466). The problem is generated user-token does not seems to work, despite the fact that my user have permissions to create projects.

curl requests failed with 302 code and HTML login page:

curl -u MY_USER_TOKEN: "https://sonarqube.infrastructure.mycompany.com/api/alm_integrations/search_gitlab_repos?almSetting=gitlab&projectName=appjs-xxx&p=1&ps=50"

Just an important note is that everyone in our organization log in into SonarQube through OKTA. Do you have any ideas why it does not work and how it can be fixed?


I’m guessing that your SonarQube server is actually served at https://sonarqube.infrastructure.mycompany.com/sonar or something, and you’re missing that end bit (/sonar/). Am I right? :smiley:

No, the API request url is correct.

I double checked network tab in UI and can confirm that all API requests are served from https://sonarqube.infrastructure.mycompany.com, like https://sonarqube.infrastructure.mycompany.com/api/alm_settings/list?

Well, I guess you need to figure out what layer is serving the 302 – is it appearing in the access.log of your SonarQube instance, or at a different layer (a reverse proxy sitting in front of your SonarQube server, for example).