久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為令牌調(diào)用 Microsoft Graph API 會出現(xiàn)錯誤“AADSTS9

Calling an Microsoft Graph API for token gives error quot;AADSTS900144: The request body must contain the following parameter: #39;grant_type#39;(為令牌調(diào)用 Microsoft Graph API 會出現(xiàn)錯誤“AADSTS900144:請求正文必須包含以下
本文介紹了為令牌調(diào)用 Microsoft Graph API 會出現(xiàn)錯誤“AADSTS900144:請求正文必須包含以下參數(shù):“grant_type"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在調(diào)用 Graph API URL

https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token

獲取訪問令牌,但我收到以下響應.

<代碼>{錯誤":無效請求","error_description": "AADSTS900144: 請求正文必須包含以下參數(shù):'grant_type'.
跟蹤 ID: 5ff6b053-9011-4397-89ff-fdb6f31e4600
相關 ID: 22509847-199d-4bd8-a083-b29d8bbf3139
時間戳:2020-04-01 11:14:00Z",錯誤代碼":[900144],"時間戳": "2020-04-01 11:14:00Z",trace_id":5ff6b053-9011-4397-89ff-fdb6f31e4600",correlation_id":22509847-199d-4bd8-a083-b29d8bbf3139",error_uri":https://login.microsoftonline.com/error?code=900144"}

我有一個活動的租戶 ID,我有一個注冊的應用程序,并且我有一個上述應用程序的活動用戶說 user@tenant.onmicrosoft.com;該用戶具有所有角色(全局管理員).

請在下方找到 Postman 的請求和響應.

解決方案:

你在嘗試錯誤的方式.您必須使用 key-value 對 在郵遞員的 form-data 中發(fā)送所需的參數(shù),格式如下:

grant_type:client_credentialsclient_id:b6695c7be_YourClient_Id_e6921e61f659client_secret:Vxf1SluKbgu4PF0Nf_Your_Secret_Yp8ns4sc=范圍:https://graph.microsoft.com/.default

代碼片段:

//令牌請求端點字符串 tokenUrl = $"https://login.microsoftonline.com/YourTenant.onmicrosoft.com/oauth2/v2.0/token";var tokenRequest = new HttpRequestMessage(HttpMethod.Post, tokenUrl);//我正在使用 client_credentials 作為它主要推薦tokenRequest.Content = new FormUrlEncodedContent(new Dictionary<string, string>{["grant_type"] = "client_credentials",["client_id"] = "b6695c7be_YourClient_Id_e6921e61f659",["client_secret"] = "Vxf1SluKbgu4PF0Nf_Your_Secret_Yp8ns4sc=",["范圍"] = "https://graph.microsoft.com/.default"});動態(tài)json;AccessTokenClass 結果 = new AccessTokenClass();HttpClient 客戶端 = 新 HttpClient();var tokenResponse = await client.SendAsync(tokenRequest);json = 等待 tokenResponse.Content.ReadAsStringAsync();結果 = JsonConvert.DeserializeObject(json);

使用的類:

公共類AccessTokenClass{公共字符串 token_type { 獲取;放;}公共字符串 expires_in { 獲取;放;}公共字符串資源 { 獲取;放;}公共字符串 access_token { 獲取;放;}}

您可以參考 官方文檔

希望這會有所幫助.如果您仍有任何疑慮,請隨時分享.

I am calling a Graph API URL

https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token

to get an access token but I am getting the following response.

{
    "error": "invalid_request",
    "error_description": "AADSTS900144: The request body must contain the following parameter: 'grant_type'.
Trace ID: 5ff6b053-9011-4397-89ff-fdb6f31e4600
Correlation ID: 22509847-199d-4bd8-a083-b29d8bbf3139
Timestamp: 2020-04-01 11:14:00Z",
    "error_codes": [
        900144
    ],
    "timestamp": "2020-04-01 11:14:00Z",
    "trace_id": "5ff6b053-9011-4397-89ff-fdb6f31e4600",
    "correlation_id": "22509847-199d-4bd8-a083-b29d8bbf3139",
    "error_uri": "https://login.microsoftonline.com/error?code=900144"
}

I have an active tenantid, I have an application registered, and I have an active user for the above application say user@tenant.onmicrosoft.com; that user has ALL the roles (Global Administrator).

Please find below Postman's request and Response. PostmanSnap

Also I have given API permission as suggested in https://docs.microsoft.com/en-us/graph/api/group-post-members?view=graph-rest-1.0&tabs=http

解決方案

Problem: I have successfully reproduced your error. As you seen below:

Solution:

You are trying in wrong way. You have to send required parameter in form-data on postman with key-value pairs like below format:

grant_type:client_credentials
client_id:b6695c7be_YourClient_Id_e6921e61f659
client_secret:Vxf1SluKbgu4PF0Nf_Your_Secret_Yp8ns4sc=
scope:https://graph.microsoft.com/.default

Code Snippet:

  //Token Request End Point
    string tokenUrl = $"https://login.microsoftonline.com/YourTenant.onmicrosoft.com/oauth2/v2.0/token";
    var tokenRequest = new HttpRequestMessage(HttpMethod.Post, tokenUrl);

    //I am Using client_credentials as It is mostly recommended
    tokenRequest.Content = new FormUrlEncodedContent(new Dictionary<string, string>
    {
        ["grant_type"] = "client_credentials",
        ["client_id"] = "b6695c7be_YourClient_Id_e6921e61f659",
        ["client_secret"] = "Vxf1SluKbgu4PF0Nf_Your_Secret_Yp8ns4sc=",
        ["scope"] = "https://graph.microsoft.com/.default" 
    });

    dynamic json;
    AccessTokenClass results = new AccessTokenClass();
    HttpClient client = new HttpClient();

    var tokenResponse = await client.SendAsync(tokenRequest);

    json = await tokenResponse.Content.ReadAsStringAsync();
    results = JsonConvert.DeserializeObject<AccessTokenClass>(json);

Class Used:

public class AccessTokenClass
   {
        public string token_type { get; set; }
        public string expires_in { get; set; }
        public string resource { get; set; }
        public string access_token { get; set; }
   }

You could refer to Official document

Hope that would help. If you still have any concern feel free to share.

這篇關于為令牌調(diào)用 Microsoft Graph API 會出現(xiàn)錯誤“AADSTS900144:請求正文必須包含以下參數(shù):“grant_type"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發(fā)技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 久久久久黄| 我爱操 | 午夜电影网 | 91久久久久久久久 | 午夜精品久久久久久久99黑人 | 久草在线影 | 久久久www成人免费精品 | 精品国产一区二区在线 | 久久精品在线免费视频 | 精品美女视频在线观看免费软件 | www.一区二区三区.com | 久久久亚洲 | 欧美激情a∨在线视频播放 成人免费共享视频 | 欧美mv日韩mv国产网站91进入 | 成人在线观看网站 | 成年人在线观看视频 | 色视频网站免费 | 亚洲 中文 欧美 日韩 在线观看 | 欧美二区在线 | 91免费看片神器 | 成人精品一区二区三区中文字幕 | 久色网| 爱爱无遮挡 | 狠狠亚洲 | 成人欧美日韩一区二区三区 | 亚洲 中文 欧美 日韩 在线观看 | 欧美精品啪啪 | aaaaaa大片免费看最大的 | 精品国产一区二区在线 | 天堂成人av | 久久精品一区 | 亚洲国产精品一区二区第一页 | 国产精品久久久久一区二区三区 | re久久 | 日韩在线免费视频 | 久久这里只有 | 一区二区精品 | 国产在线高清 | 欧美一级片中文字幕 | 国产免费观看一区 | 日本一区二区三区视频在线 |