简体   繁体   中英

How to get access token in azure Active directory in Angular2

我开始学习Oath 2,我需要从前端侧(角度2)获取访问令牌,而无需显示Microsoft登录页面,对此有任何选择,请与我分享,谢谢。

There are two kinds of token which Azure AD could issue.

First is the delegated token which used to delegate the sign-in user. And normally this kind of token required to users sign-in( Authorization Code Grant flow ). However if there is a high degree of trust between the resource owner and the client, we can also use Resource Owner Password Credentials flow which using users' username and password in code directly without users participate.

And the second kind of token is delegated the application called app-only token. To acquire this kind of token, we can use the app's key or the certificate without users sign-in( Client credentials flow ).

If you were developing with Client credentials flow , you can refer here which acquire the token for Microsoft Graph using Client credentials flow .

Update

To acquire the token using the Client Credentials flow for multi-tenant apps, we need to grant the permission to the application to register the service principal to the customers' tenant. We can use the Code grant flow to grant the permission. More detail about the multi-tenant apps, you can refer here .

To init the code grant flow , you can refer the request sample from here . After the you grant the permission, the customer also could see this application on their portal. Then you can use the the client credentials flow to reacquire the token from customers' tenant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM