我正在使用 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;
}
}
我正在尝试针对Google和WindowsLive进行身份验证,但在这两种情况下都没有成功。
谷歌
这些是用于访问 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
吗?
预先感谢。