我正在使用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
的实际例子吗?
谢谢你。
答案 0 :(得分:1)
资源所有者凭据授予仅在授权服务器允许时才有效。我相信谷歌和微软都故意不支持这一点,因为他们不希望第三方应用直接获取用户凭证。