首页 文章

Google身份验证Redirect_uri_missmatch错误

提问于
浏览
2

我已经检查了其他人的所有可能的解决方案,并应用于我的应用程序或代码设置,但没有任何对我有用 .

这是我传递给baseUrl https://accounts.google.com/o/oauth2/auth 的参数

  • 范围: https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile

  • client_id: xxxxxxxx.apps.googleusercontent.com

  • redirect_uri: http://localhost:8228/Auth/ExternalLoginCallback?__provider__=Google&__sid__=xxxxxxxxxxxxxxxxxxxx

  • 州: xxxxxxxxxxxxxxxxxxxx

  • response_type: code

  • access_type: online

我错过了什么?请有人给我建议 .

我每次都有以下错误:

enter image description here

这是我的应用程序信息:
enter image description here

Update 1:

这是我为google的 RequestAuthentication 方法类的代码:

public GoogleScopedClient(string cleintId, string clientSecretId)
        {
            this.cleintId = cleintId;
            this.clientSecretId = clientSecretId;
        }

        public string ProviderName
        {
            get { return "Google"; }
        }

        public void RequestAuthentication(System.Web.HttpContextBase context, Uri returnUrl)
        {
             string state = Regex.Match(returnUrl.AbsoluteUri, "(?<=__sid__=).*?($|&)", RegexOptions.IgnoreCase).Value;

            string url = baseUrl + HttpUtility.UrlEncode(SCOPE.ToString()) +
                "&client_id=" + cleintId + "&redirect_uri=" +HttpUtility.UrlEncode(returnUrl.ToString()) 
+"&response_type=code&access_type=online";
  context.Response.Redirect(url);
        }

1 回答

  • 0

    您在Google Developer Console中指定的重定向URI不是 http://localhost:8228/Auth/ExternalLoginCallback/ ,但发送的是 http://localhost:8228/Auth/ExternalLoginCallback (没有斜杠) . 这些实际上是两个完全不同的URL,即使它们通常会到达同一个地方 .

相关问题