Cannot re-enter PAT to create Azure DevOps project

  • version: SonarQube EE
  • error:
Unable to contact Azure server, got an unexpected response
  • steps to reproduce:
    • pre-requisities: already have Azure DevOps ALM set up in general settings
    • log in as user who has Create Project permissions but has not attempted to create a project before
    • Attempt to create Azure DevOps project
    • User will be prompted to enter an Azure DevOps PAT
    • User enters an invalid PAT
    • User now unable to create Azure DevOps project because they are never prompted to re-enter a PAT. Instead only get an alert Unable to contact Azure server, got an unexpected response even after re-logging or attempting in private/incognito browsing window.
  • Potential workaround: none found so far. Have tried:
    • Logging out and back in
    • Clearing browser cache
    • Using incognito
    • Using different browser
    • Changing ALM name in General Settings

It seems like I have accidentally gotten my User to be in an invalid state by entering an invalid Azure DevOps PAT when attempting to create and Azure DevOps project. Is there a way to fix this invalid state so that I am once again prompted to enter a PAT?

Hey @ahaleiii ,

You can directly reset your PAT through SQ API:

curl -u {SQ user}:{SQ password} -X POST ‘{SQ Base Url}/api/alm_integrations/set_pat?almSetting={Your Azure Setting Key}&pat={Your new PAT}’

Let us know if this does the trick :slight_smile:

Kind regards,

1 Like

Thank you @Belen_Pruvost, that worked.

I ended up using PowerShell because we have a self signed cert somewhere:

curl: (60) SSL certificate problem: self signed certificate in certificate chain

The specific steps I took to resolve (in PowerShell v7.1.3):

# Pre-requisites: generate SonarQube User Token and Azure DevOps PAT
$sonarqubeUserToken = '<my_user_token>'
$azdoPat = '<my_azdo_pat>'

$sonarqubeBaseUrl = '<my_instance_url>'
$almSettingKey = '<my_alm_setting>'

$plainAuth = "{0}:" -f $sonarqubeUserToken
$base64Auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($plainAuth))
$headers = @{ Authorization = "Basic $base64Auth" }

# POST api/alm_integrations/set_pat
$uriTemplate = '{0}/api/alm_integrations/set_pat?almSetting={1}&pat={2}'
$uri = $uriTemplate -f $sonarqubeBaseUrl, $almSettingKey, $azdoPat

Invoke-RestMethod -Uri $uri -Method POST -ContentType 'application/json' -Headers $headers
1 Like

That’s great! Thanks @ahaleiii for sharing :tada:

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