S.Chandra Sekhar
S.Chandra Sekhar

Reputation: 503

How to get access token for Azure DevOps from Microsoft Teams app?

I have created an angular app and integrated with MS Teams using tab.

I'm also able to authenticate user within microsoft teams app and able to get logged in user token using Microsoft Teams Javascript SDK.

https://learn.microsoft.com/en-us/javascript/api/overview/msteams-client?view=msteams-client-js-latest#using-the-sdk

I'm not getting how to authenticate Azure DevOps within MS Teams app.

How to get access token for Azure DevOps within my custom teams angular app, so that I can use it to deal with Azure DevOps?

Upvotes: 1

Views: 1765

Answers (1)

Carl Zhao
Carl Zhao

Reputation: 9549

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.

enter image description here

enter image description here

Next, use the auth code flow to obtain an access token.

  1. 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.

enter image description here

Parse the token and view the aud claim.

enter image description here

The token will contain the logged-in user information, and have full access to Visual Studio Team Services REST APIs.

sample.

Upvotes: 1

Related Questions