1

我正在使用 DotNetOpenAuth 对用户进行身份验证,但无法使其正常工作。这是我的代码:

public string AuthenticateUser(
     string key, string secret, string user, string password,
     AuthorizationServerDescription serviceDescription)
{
    UserAgentClient agent = new UserAgentClient(
        serviceDescription,
        key,
        secret);

    IAuthorizationState authState = mConsumer.ExchangeUserCredentialForToken(
        user,
        password,
        GetScope());

    if (authState != null)
    {
        return authState.Token;
    }
}

我正在尝试针对GoogleWindowsLive进行身份验证,但在这两种情况下都没有成功。

谷歌

这些是用于访问 Google OAuth 服务的配置参数:

        AuthorizationEndpoint = new Uri("https://accounts.google.com/o/oauth2/auth")
        TokenEndpoint = new Uri("https://accounts.google.com/o/oauth2/token")
        ProtocolVersion = ProtocolVersion.V20
        State = "/profile"
        Scope = "https://www.googleapis.com/auth/userinfo.email"

获得的错误:

---------------------------
Error
---------------------------
Error occurred while sending a direct message or getting the response.
---------------------------
OK   
---------------------------

视窗直播

这些是用于访问 Windows Live Outh 服务的参数:

        TokenEndpoint = new Uri("https://oauth.live.com/token"),
        AuthorizationEndpoint = new Uri("https://oauth.live.com/authorize")
        ProtocolVersion = ProtocolVersion.V20
        State = null
        Scope = "wl.signin"

获得的错误:

---------------------------
Error
---------------------------
Unexpected response Content-Type text/html
---------------------------
OK   
---------------------------

我还ClientCredentialApplicator以各种方式测试了使用:

  • 网络凭证
  • 没有秘密
  • 后置参数

难道我做错了什么?有人可以给我看一个工作的例子ExchangeUserCredentisForToken吗?

预先感谢。

4

1 回答 1

1

资源所有者凭据授予仅在授权服务器允许时才有效。我相信谷歌和微软都故意不支持这一点,因为他们不希望第三方应用程序直接获取用户凭据。

于 2013-03-09T18:46:33.340 回答