Getting OAuth tokens for Azure DevOps API consumption

你。 提交于 2020-01-15 08:50:14

问题


I have a web app written in Angular 7. I'm trying to consume Azure DevOps APIs and I understand that I have to setup an Azure Active Directory App. I have tried few libraries like adal-angular msal-angular and wrappers like microsoft-adal-angular6. Followed their documentations and samples. I can successfully access the User's name, emails and a token. I can use the token for Microsoft Graph apis but not for Azure DevOps apis. I tried using this token as a Authentication Bearer for my HttpClient however I'm getting Status Code 203.

Then I found this answer and I think this is the missing part that I need but its for dotNet.

The API Im cosuming: https://app.vssps.visualstudio.com/_apis/accounts

Q:

  1. What is the token Im getting?
  2. How can I get the appropriate token using Angular 7?
  3. What libraries do I need?

回答1:


I used @azure/msal-angular. I got the azure dev ops token using acquireTokenSilent(['499b84ac-1321-427f-aa17-267ca6975798/.default']). If it fails, I used the acquireTokenRedirect(['499b84ac-1321-427f-aa17-267ca6975798/.default'])

access token can be retrieved via getCachedTokenInternal([499b84ac-1321-427f-aa17-267ca6975798/.default])



来源:https://stackoverflow.com/questions/56355274/getting-oauth-tokens-for-azure-devops-api-consumption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!