DotNetOpenAuth - UserAgentClient :: ExchangeUserCredentialForToken - 如何传递redirect_uri参数

时间:2017-02-02 16:33:33

标签: dotnetopenauth

尝试使用DotNetOpenAuth库检索OAuth2.0 AccessToken,编码方式如下 - https://github.com/DotNetOpenAuth/DotNetOpenAuth/wiki/Security-scenarios

private static IAuthorizationState GetAccessTokenFromOwnAuthSvr()
{
   var server = new AuthorizationServerDescription();
   server.TokenEndpoint = new Uri("https://localhost/STS/OAuth/Token");
   server.ProtocolVersion = DotNetOpenAuth.OAuth2.ProtocolVersion.V20;

   var client = new UserAgentClient(server, clientIdentifier: "RP");

   client.ClientCredentialApplicator = 
                ClientCredentialApplicator.PostParameter("data!");

   var token = client.ExchangeUserCredentialForToken(
                 "Max Muster", "test123", new[] { "http://localhost/demo"});

   return token;
}

这不起作用,因为AuthZ服务器返回错误,抱怨缺少redirect_uri。

通过这里的一些链接,看到 AuthorizationState 具有 redirect_uri 选项,但无法弄清楚如何传递 AuthorizationState ExchangeUserCredentialForToken请求中的对象。

有没有办法在ExchangeUserCredentialForToken请求中发送 redirect_uri 参数或 AuthorizationState 对象?

提前致谢

- Abraham V K

0 个答案:

没有答案