Forum Discussion
How to receive azure devops session token via API?
Thank you for your questions,evaalemftech
A POST request to the "https://dev.azure.com/Organization/%20apis/WebPlatformAuth/SessionToken" endpoint will return the Azure DevOps session token.
To make the request, include a JSON payload with the "appId" value and an authentication method, typically a Personal Access Token (PAT). Here's an example of a request that could be made with CURL:
curl -X POST \
https://dev.azure.com/{Organization}/_apis/WebPlatformAuth/SessionToken \
-H 'Authorization: Bearer {PAT}' \
-H 'Content-Type: application/json' \
-d '{
"appId": "{appId}",
"name": null,
"token": null,
"force": null,
"tokenType": 0
}'The appId is a string that identifies the app making the request, and the PAT is the authentication token.
If you receive an "Access denied" error, the PAT you are using might lack the necessary permissions to retrieve the session token.
For more information on the required permissions, see https://docs.microsoft.com/en-us/azure/devops/authentication/permission-scopes?view=azure-devops.