OneDrive for Business身份验证和登录:“错误”:“invalid

编程入门 行业动态 更新时间:2024-10-08 18:31:25
本文介绍了OneDrive for Business身份验证和登录:“错误”:“invalid_request”,“error_description”:“AADSTS90014:请求正文必须包含以下参数:'grant_type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将OneDrive for Business集成到Web表单应用程序。 为此,我使用此URL提供的文档。 b $ b dev.onedrive/auth/ aad_oauth.htm 在Web表单应用程序中我有两个页面。第一个是登录页面,其中有一个登录按钮 在按钮登录中单击我正在使用发送GET请求到OneDrive for Business API以下 $ 以下代码

I m trying to integrate the OneDrive for Business to a Web Form App. For this i am using the documentation given at this url dev.onedrive/auth/aad_oauth.htm In web Form App I have two Page First one is Login page which have a button for login In button login click i am making a GET Request to OneDrive for Business API using the following code

HttpClient client = new HttpClient(); Redirecturi = Uri.EscapeDataString(Redirecturi); string url = string.Format ("login.windows/common/oauth2/authorize?response_type=code&client_id= {0}&redirect_uri={1}", ClienId, Redirecturi); var response = client.GetAsync(url); var json = response.Result.Content.ReadAsStringAsync(); Label2.Text = json.Result;

$ 当我点击在登录按钮上它带我到micorosoft登录服务并发送 我回到带有访问代码的callback.aspx页面(在azure上配置重定向URi) 我获得了访问代码 在第二页我正在兑换访问代码和发出POST请求以获得 $ 身份验证令牌 以下是第二页的代码。

When I Click on login button it is taking me to micorosoft login servie and sending me back to callback.aspx page with access code (Redirect URi configured on azure) I got the access code On second page i am redeeming the access code and making a POST request to get the Authentication token Here is the code for the second page.

private string BaseUri="login.windows/common/oauth2/token"; public string Redirecturi = "localhost:51642/CallBack.aspx"; public string ResourcesId = "api.office/discovery/"; private string ClienId = "180c6ac4-5829-468e-.....-822405804862"; ///truncated//azure private string ClientSecert = "G4TAQzD8d7C4...OE6m366afv8XKbTCcyXr4=";//truncated protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString [OAuthConstants.AccessToken])) { // There is a token available already. It should be the token flow. Ignore it. return; } if (!string.IsNullOrEmpty(Request.QueryString[OAuthConstants.Code])) { string _accessCode = Request.QueryString[OAuthConstants.Code]; HttpClient client = new HttpClient(); // BaseUri = Uri.EscapeDataString(BaseUri); Redirecturi = Uri.EscapeDataString(Redirecturi); ResourcesId = Uri.EscapeDataString(ResourcesId); string url = string.Format("{0}?client_id={1}&redirect_uri={2} &grant_type=authorization_code&client_secret={3}&code={4} &grant_type=authorization_code&resource={5}", BaseUri, ClienId, Redirecturi, ClientSecert, _accessCode, ResourcesId); var response = client.PostAsync(url, null); var json = response.Result.Content.ReadAsStringAsync(); Response.Write(json); } } But instead of Response i am getting following error. Which say include the grant_type in url. I already added (u can check in code). Without including this also i am getting same error. **Here is error** {"error":"invalid_request","error_description":"AADSTS90014: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: 2adb3a7f-ceb1-4978- 97c4-3dc2d3cc3ad4\r\nCorrelation ID: 29fb11a0-c602-4891-9299-b0b538d75b5f\r \nTimestamp: 2015-07-15 09:58:42Z","error_codes":[90014],"timestamp":"2015-07-15 09:58:42Z","trace_id":"2adb3a7f-ceb1-4978-97c4- 3dc2d3cc3ad4","correlation_id":"29fb11a0-c602-4891-9299- b0b538d75b5f","submit_url":null,"context":null}

$ 请帮助知道错误的地点。 任何形式的帮助都会很明显。非常感谢提前付款b

Ramakant Verma .NET顾问(Windows Azure,Windows Phone8,Windows 8,ASP.NET,Silverlight)

please help to know where , what geting wrong. Any kind of help will be appreciable Thanks a lot in advance

Ramakant Verma .NET Consultant(Windows Azure, Windows Phone8,Windows 8,ASP.NET,Silverlight)

推荐答案

您发布的论坛错误。

You are posting to the wrong forum.

forums.asp/

更多推荐

OneDrive for Business身份验证和登录:“错误”:“invalid

本文发布于:2023-11-26 23:37:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   错误   OneDrive   Business   invalid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!