【问题标题】:State parameter value does not match with expected value状态参数值与期望值不匹配
【发布时间】:2015-02-14 19:14:19
【问题描述】:

我在我们的项目中要求使用 facebook、google 等其他提供商登录用户。为此,我正在使用社交身份验证插件。它在 facebook 上运行良好,但在 googleplus 上,我收到错误“状态参数值与预期值不匹配”,当用户在谷歌之后在我们的应用程序中重定向时出现此错误,意味着在 getUserProfile() 中。所以我该如何解决这个。

Dependencies are :
runtime "org.brickred:socialauth:4.7"
        compile "org.brickred:socialauth:4.7"

我的 socialauth 控制器是

def authenticate(){
            SocialAuthConfig config = SocialAuthConfig.getDefault()
            //You can also pass input stream, properties object or properties file name.
            config.load()
            //Create an instance of SocialAuthManager and set config
            SocialAuthManager manager = new SocialAuthManager()
            manager.setSocialAuthConfig(config)
            // URL of YOUR application which will be called after authentication
            String successUrl = grailsApplication.config.auth.redirect.url
            // get Provider URL to which you should redirect for authentication.
            // id can have values "facebook", "twitter", "yahoo" etc. or the OpenID URL
            String url = manager.getAuthenticationUrl(params.id, successUrl)
            session.setAttribute("authManager", manager)
            redirect (url:url)
        }

        @Secured('permitAll')
        def getUserProfile(){
            try{
                // get the auth provider manager from session
                SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");
                // Pass request parameter map while calling connect method.
                Map<String, String> paramsMap = SocialAuthUtil.getRequestParametersMap(request);
                // call connect method of manager which returns the provider object.
                AuthProvider provider = manager.connect(paramsMap);
                Profile profile = provider.getUserProfile();
                log.debug"user profile"+profile
    //          log.debug"contact"+  provider.getContactList()
            }
            catch(SocialAuthManagerStateException exception){
                log.error("Exception occurs while connecting with SocialAuthManager--->"+exception.getMessage())
            }
        }

属性文件

#googleplus
googleapis.com.consumer_key = XXXXXXXXXXXXXX
googleapis.com.consumer_secret = XXXXXXXXXXXXXXX

【问题讨论】:

  • social auth 4.7有问题,使用social auth 4.6,问题解决了

标签: java grails oauth google-oauth social-authentication


【解决方案1】:

这是 Version 的问题,你可以使用 social auth 4.6 ,它工作正常

【讨论】:

    猜你喜欢
    • 2021-08-05
    • 2016-07-13
    • 1970-01-01
    • 2018-09-02
    • 2016-04-22
    • 2020-11-29
    • 2015-12-13
    • 2016-09-18
    • 2014-04-06
    相关资源
    最近更新 更多