OneDrive for Business身份验证和登录:“错误”:“invalid_request”,“error_description”:“AADSTS90014:请求正文必须包含以下参数:'grant_type [英] OneDrive for Business authentication and sign in :"error":"invalid_request","error_description":"AADSTS90014: The request body must contain the following parameter: 'grant_type

查看:1236
本文介绍了OneDrive for Business身份验证和登录:“错误”:“invalid_request”,“error_description”:“AADSTS90014:请求正文必须包含以下参数:'grant_type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试将OneDrive for Business集成到Web表单应用程序。

为此,我使用此URL提供的文档。 b $ b

https://dev.onedrive.com/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

https://dev.onedrive.com/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

("https://login.windows.net/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="https://login.windows.net/common/oauth2/token";
        public string Redirecturi = "http://localhost:51642/CallBack.aspx";
        public string ResourcesId = "https://api.office.com/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.

http://forums.asp.net/


这篇关于OneDrive for Business身份验证和登录:“错误”:“invalid_request”,“error_description”:“AADSTS90014:请求正文必须包含以下参数:'grant_type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆