0
votes

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://docs.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?

1
Is the application created in Azure AD?Carl Zhao
If the posted answer resolves your question, please mark it as the answer by clicking the check mark. Doing so helps others find answers to their questions. See: meta.stackexchange.com/questions/5234/…Carl Zhao

1 Answers

0
votes

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.