简体   繁体   English

使用DotNetOpenAuth时出现400错误的请求

[英]400 Bad request when using DotNetOpenAuth

I am using DotNetOpenAuth to implement OAuth in my local system. 我正在使用DotNetOpenAuth在本地系统中实现OAuth。 Everytime I am getting the following error : + 每当我遇到以下错误时:+

ex.InnerException   {"The remote server returned an error: (400) Bad Request."} System.Exception {System.Net.WebException}

Below is my code snippet 以下是我的代码段

  AuthorizationServerDescription authServer = new AuthorizationServerDescription()
{
    TokenEndpoint = new Uri(TOKEN_ENDPOINT),
    AuthorizationEndpoint = new Uri(AUTHZ_ENDPOINT),
};

                string[] scopes = new string[] { "Scope" };
                var client = new WebServerClient(authServer , "ClientId", "Client_Secret");


                var token= client.ExchangeUserCredentialForToken("username", "password");

When client.ExchangeUserCredentialForToken is called then I am getting error. 调用client.ExchangeUserCredentialForToken时,出现错误。 Couldn't figure out what wrong is happening. 无法弄清楚发生了什么错误。 What can be the potential reason? 可能是什么原因?

您未在请求中提供范围,请尝试在最后一个参数中添加范围:

client.ExchangeUserCredentialForToken("username", "password", scopes);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM