Azure Active Directory (Azure AD) is Microsoft’s cloud-based identity and access management service, which helps your employees sign in and access resources in Azure.api
當咱們使用REST API調用Azure上任何資源的時候,都須要在Request Header中提供Authorization的值。ide
如何獲取Authorizatoin的值呢?工具
如下內容則主要介紹如何經過AAD API獲取Token(常規的操做方式)。ui
1,獲取spa
3,獲取3d
在應用的概述(Overview)頁面中複製出租戶(tenant),客戶端()。見上圖中的三組GUID數字。rest
4,獲取客戶端密碼[client_secret]orm
scope:jwt |
https://microsoftgraph.chinacloudapi.cn/.default |
grant_type: | client_credentials |
使用Postman調用Token終結點,所有的參數爲:blog
請求方式 | POST |
請求URL | https://login.chinacloudapi.cn/{TENANT}/oauth2/v2.0/token |
請求Body | |
tenant:{TENANT} |
|
請求成功後的響應Body |
|
{
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 3599,
"access_token": "eyJ0eXAiOiJKV1QiLCJub25jZSI6IjFJRk1tbFNMcnV1 ... ... ... ... W0Da3_LzLhdNA"
}
|
Postman截圖說明:
獲取到access_token的值後,便可做爲Auzre REST API接口中Authroization的值。
訪問https://jwt.io/,能夠解碼Token內容,查看當前Token中所攜帶的權限(Role). 演示操做:
什麼是 Azure Active Directory?https://docs.azure.cn/zh-cn/active-directory/fundamentals/active-directory-whatis
Microsoft Graph REST API v1.0 reference: https://docs.microsoft.com/en-us/graph/api/overview?view=graph-rest-1.0
附錄一:經過F12(開發者工具)中查看Network中Request的Header中的Authorization值