Forum Discussion
surendra-p
Dec 09, 2024Copper Contributor
How to fetch the user in azure devOps using API
I am using the azure board API. I want to know is there any API to fetch the user which is associated with the PAT token provided. Basically, want to verify if a valid user exists for associated PAT ...
balasubramanim
Dec 13, 2024Iron Contributor
To fetch the user associated with a PAT (Personal Access Token) in Azure DevOps, you can use the Profile API. please try the following API's
Endpoint - GET https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=7.1-preview.1
Authorization Header: Encode your PAT as :PAT in Base64 and include it:
Authorization: Basic BASE64_ENCODED_PAT
Example using curl
curl -X GET \
-H "Authorization: Basic $(echo -n :YOUR_PAT | base64)" \
https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=7.1-preview.1
Response: If valid, you'll get user details like displayName and emailAddress. If invalid, you'll get a 401 Unauthorized error