Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 400使用DotNetOpenAuth时请求错误_C#_Oauth_Https_Oauth 2.0_Dotnetopenauth - Fatal编程技术网

C# 400使用DotNetOpenAuth时请求错误

C# 400使用DotNetOpenAuth时请求错误,c#,oauth,https,oauth-2.0,dotnetopenauth,C#,Oauth,Https,Oauth 2.0,Dotnetopenauth,我正在使用DotNetOpenAuth在本地系统中实现OAuth。每次出现以下错误时:+ ex.InnerException {"The remote server returned an error: (400) Bad Request."} System.Exception {System.Net.WebException} 下面是我的代码片段 AuthorizationServerDescription authServer = new AuthorizationServerDe

我正在使用DotNetOpenAuth在本地系统中实现OAuth。每次出现以下错误时:+

ex.InnerException   {"The remote server returned an error: (400) Bad Request."} System.Exception {System.Net.WebException}
下面是我的代码片段

  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");

当调用client.ExchangeUserCredentialForToken时,我得到一个错误。不知道发生了什么事。可能的原因是什么?

您没有在请求中提供作用域请尝试将其添加到最后一个参数:

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

您没有在请求中提供作用域。请尝试将其添加到最后一个参数:

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