Assuming your application is in Azure AD, it is very simple to obtain an access token for Azure DevOps, you only need to set the scope to: https://app.vssps.visualstudio.com/user_impersonation
.
First, you need to grant the Azure DevOps user_impersonation
delegation permission to the application, and then use the auth code flow to obtain an access token.
Next, use the auth code flow to obtain an access token.
- Request an authorization code in the browser.
https://login.microsoftonline.com/{tenant id}/oauth2/v2.0/authorize?
client_id={client id}
&response_type=code
&redirect_uri={redirect_uri}
&response_mode=query
&scope=https://app.vssps.visualstudio.com/user_impersonation
&state=12345
2.Redeem token.
Parse the token and view the aud
claim.
The token will contain the logged-in user information, and have full access to Visual Studio Team Services REST APIs.
sample.