Edit

Share via


"Failed to get Azure DevOps Service access token" error

Symptoms

When you try to verify the automatic Azure RM service connection, you may receive the following error message:

Failed to get Azure DevOps Service access token, cache value is invalid.

Screenshot that shows verification of the automatic Azure RM connection.

Debugging steps

Capture an F12/Fiddler trace while you reproduce the issue.

You will see following response for the POST call in the trace:

{"authorization":{"parameters":{"tenantid":"xxxxxx49-XXXXcexxxxxx","serviceprincipalid":"xxxxxx7e-XXXX-027xxxxxxxxx","authenticationType":"spnKey","serviceprincipalkey":null,"**accesstoken":null**},"scheme":"ServicePrincipal"},"created}

Cause

When you run a service connection update call from the UI, the body of the PUT request contains an accesstoken = null entry. If we compare the PUT payload against the working service connections at either end of the operation, we don't see this entry. If the AccessToken property is present in the service connection UI object, it should have valid value (such as a GUID). It shouldn't be empty or null.

Resolution

  1. Go to the service connection page, and then select the affected service connection.

  2. Select Edit.

  3. Press F12, and then open the network trace window. If possible, select the Disable cache option in the panel under the Network tab.

  4. Update the description.

  5. Select the Save button.

  6. If you are prompted for authorization, enter the required credentials. In network trace, you can now see the PUT call to update the service connection that failed.

  7. Open the PUT call details, and copy the Request Payload by selecting Payload > view source > Select the content and copy the content.

  8. From the PUT call details, also copy the Authorization header value.

  9. In the request body, remove the accesstoken: null (or accesstoken:'') property under the authorization header.

  10. Copy the updated Request payload, and make a service connection update PUT API call by using Postman (or any other REST tool) by running the following API. Make sure to provide the Authorization header you copied earlier when making this call.

    PUT - https://dev.azure.com/{organization}/_apis/serviceendpoint/endpoints/{endpointId}?api-version=6.0-preview.4

For more information, see Endpoints - Update Service Endpoint.