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

為令牌調用 Microsoft Graph API 會出現錯誤“AADSTS9

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

問題描述

限時送ChatGPT賬號..

我正在調用 Graph API URL

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

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

<代碼>{錯誤":無效請求","error_description": "AADSTS900144: 請求正文必須包含以下參數:'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 中發送所需的參數,格式如下:

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"});動態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.

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

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

相關文檔推薦

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屋-程序員軟件開發技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 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 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 97日日碰人人模人人澡分享吧 | 亚洲欧美日韩精品久久亚洲区 | a免费观看| 一区二区精品 | 国产伦精品一区二区三区高清 | 日本午夜在线视频 | 日韩欧美一区二区三区免费看 | 黄色在线观看网址 | 亚洲激情在线观看 | 国产美女高潮 | 色狠狠一区 | 日韩男人天堂 | 欧美激情免费在线 | 天堂在线91 | 亚洲一区二区三区在线视频 | 日本精品一区二区三区在线观看视频 | 欧美性猛交一区二区三区精品 | 亚洲精品综合一区二区 | 色又黄又爽网站www久久 | 亚洲综合热 | caoporn免费在线视频 | 日韩欧美中文字幕在线观看 | 国产成人综合在线 | 成人午夜影院 | 国产精品免费播放 | 亚洲高清免费 | 综合一区二区三区 | 中文字幕成人 | 在线91| 亚洲综合色 | 在线播放亚洲 | h视频免费在线观看 | 人人人艹 | 精品久久国产老人久久综合 | 羞羞视频网站在线观看 | 免费精品 | av在线一区二区三区 | 日韩一区二区福利 | 九九热在线视频 | 国产精品久久久久久久久免费软件 | 久久一区二区视频 |