我尝试使用OAuth 2.0进行谷歌授权使用DotNetOpenAuth库for .NET,该代码可以在Facebook上运行,但是当我请求回调谷歌端点时谷歌,当用户选择谷歌帐户后,响应只返回错误请求(状态代码) 400)
我的代码就像
public class GoogleClient : WebServerClient
{
private static readonly AuthorizationServerDescription GoogleDescription = new AuthorizationServerDescription
{
TokenEndpoint = new Uri("https://accounts.google.com/o/oauth2/token"),
AuthorizationEndpoint = new Uri("https://accounts.google.com/o/oauth2/auth"),
ProtocolVersion = ProtocolVersion.V20
};
public GoogleClient() : base(GoogleDescription) { }
}
使用
GoogleClient client = new GoogleClient
{
ClientIdentifier = ConfigurationHelper.GoogleAppId,
ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(ConfigurationHelper.GoogleAppSecret)
};
client.ProcessUserAuthorization();
我们遇到了同样的问题。我注意到scope参数包含在http post body请求的redirect_uri参数中(由于某些奇怪的原因,它没有正确编码)我认为是时候转移到另一个lib了。