java - 状态参数值与期望值不匹配

标签 java grails oauth google-oauth social-authentication

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

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

我的socialauth Controller 是

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.6,它工作正常

关于java - 状态参数值与期望值不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27505265/

相关文章:

c# - 需要 OAuth token 的单元测试 API

java - 如何在 setenv.sh 中安全地保存敏感信息

JavaFX : Not on FX application thread error occurs

java - 同时关联和依赖?

java 包裹@e7a33b1 : Unmarshalling unknown type of arraylist

mysql - 如何将 mysql 或 mongodb 集成到 grails 3.2.10

google-chrome - 在Grails中设置 session 变量时奇怪的Web浏览器行为

api - 保护未经身份验证的 REST API 的安全

grails - Grails在运行时添加 Controller Action

php - 禁用对 OAuth 调用的 SSL 检查 (PHP)