Servicestack - Google身份验证错误

时间:2017-02-06 22:18:38

标签: servicestack google-oauth

在尝试使用生产环境中的Google帐户登录时,我收到以下错误:

2017-02-06 10:34:26.8978|DEBUG|HttpResponseExtensionsInternal|Setting Custom HTTP Header: Accept-Ranges: bytes
2017-02-06 10:34:26.8978|DEBUG|HttpResponseExtensionsInternal|Setting Custom HTTP Header: Location: https://accounts.google.com/o/oauth2/auth?client_id=XXXXX.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fproductionurl.com%2Fapi%2Fauth%2FGoogleOAuth&state=xxxxxxxx&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&response_type=code
2017-02-06 10:34:26.8978|DEBUG|HttpResponseExtensionsInternal|Setting Custom HTTP Header: Content-Type: text/html; charset=utf-8
2017-02-06 10:34:26.8978|DEBUG|HttpResponseExtensionsInternal|Setting Custom HTTP Header: Cache-Control: no-cache, no-store, max-age=0, must-revalidate
2017-02-06 10:34:26.8978|DEBUG|HttpResponseExtensionsInternal|Setting Custom HTTP Header: Pragma: no-cache
2017-02-06 10:34:38.3492|WARN|StringMapTypeDeserializer|Property 'code' does not exist on type 'ServiceStack.Authenticate'
2017-02-06 10:34:38.3492|DEBUG|RedisNativeClient|S: GET urn:iauthsession:tWsIDUa1jLZAXzXYK8Ob
2017-02-06 10:34:38.3492|DEBUG|RedisNativeClient|R: $510
2017-02-06 10:34:39.0678|ERROR|AppHost|DotNetOpenAuth.Messaging.ProtocolException: Error occurred while sending a direct message or getting the response. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
  at System.Net.HttpWebRequest.GetResponse()
  at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options)
  --- End of inner exception stack trace ---
  at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options)
  at DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request)
  at DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage)
  at DotNetOpenAuth.OAuth2.ClientBase.UpdateAuthorizationWithResponse(IAuthorizationState authorizationState, EndUserAuthorizationSuccessAuthCodeResponse authorizationSuccess)
  at DotNetOpenAuth.OAuth2.WebServerClient.ProcessUserAuthorization(HttpRequestBase request)
    at ServiceStack.Authentication.OAuth2.OAuth2Provider.Authenticate(IServiceBase authService, IAuthSession session, Authenticate request)
  at ServiceStack.Auth.AuthenticateService.Authenticate(Authenticate request, String provider, IAuthSession session, IAuthProvider oAuthConfig)
  at ServiceStack.Auth.AuthenticateService.Post(Authenticate request)
  at lambda_method(Closure , Object , Object )
  at ServiceStack.Host.ServiceRunner`1.Execute(IRequest request, Object instance, TRequest requestDto)
2017-02-06 10:34:39.0990|ERROR|ServiceStackHost|ServiceBase<TRequest>::Service Exception
The remote server returned an error: (400) Bad Request.    at System.Net.HttpWebRequest.GetResponse()
  at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options)

Facebook身份验证在生产中非常完美。在开发过程中,谷歌和Facebook身份验证都运行良好,但在生产中我只是为谷歌身份验证收到此错误。

显然Google身份验证已正确完成,在网络标签的浏览器检查器中,我可以看到以下重定向:

https://productionurl.com/api/auth/GoogleOAuth?state=XXXXLiO-LQf6EoGYMw&code=XXXXXwduRVs96RIBCdkao2nQDgKDFvvQhT8

但是在最后一次验证步骤中出了问题。

生产环境落后于负载均衡器。平衡器可能是问题吗?

有没有办法更深入地研究这个问题?

1 个答案:

答案 0 :(得分:1)

由于GoogleOAuth使用DotNetOpenAuth,您可以setup your Web Application to use Glimpse更详细地记录OAuth问题。