首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SocialAuth和谷歌

SocialAuth和谷歌
EN

Stack Overflow用户
提问于 2013-03-28 01:10:32
回答 2查看 991关注 0票数 1

我正在构建一个登录模块,您可以使用各种社交网络帐户进行登录。第一步是LinkedIn和谷歌。

LinkedIn部分运行良好,但Google部分运行不正常,我认为问题出在身份验证之前的代码,因为返回的url有openid参数,而不是OAuth参数。这是重定向之前的代码:

代码语言:javascript
复制
HttpSession session = request.getSession();
SocialAuthConfig config = SocialAuthConfig.getDefault();
    try {
        config.load("/oauth_consumer.properties");
    } catch (Exception ex) {
        System.out.println(ex);
    }

    //Create an instance of SocialAuthManager and set config
    SocialAuthManager manager = new SocialAuthManager();
    try {
        manager.setSocialAuthConfig(config);
    } catch (Exception ex) {
        System.out.println(ex);
    }

    //URL of YOUR application which will be called after authentication
    String successUrl = "http://localhost:8080/ProjectName/completelogin.do";
    String url = "";
    try {
        url = manager.getAuthenticationUrl(type, successUrl).toString();
    } catch (Exception ex) {
        System.out.println(ex);
    }

    // Store in session
    session.setAttribute("authManager", manager);

    response.sendRedirect(url);

这是我为谷歌提供的oauth_consumer.properties部分

代码语言:javascript
复制
www.google.com.consumer_key = 81XXXXXX466.apps.googleusercontent.com
www.google.com.consumer_secret = WN0oXXXXXXXHoCeSocQK
www.google.com.custom_permissions=https://www.googleapis.com/auth/userinfo.profile,https://www.googleapis.com/auth/userinfo.email

我可以强制谷歌使用OAuth身份验证来代替OpenID身份验证吗?我用另一个使用OAuth的框架登录了谷歌,它工作得很棒。只是现在,因为我想使用几个社交网站,所以我不想一直重复发明轮子,只使用socialauth…

EN

回答 2

Stack Overflow用户

发布于 2013-03-29 05:45:05

Google身份验证端点是https://accounts.google.com/o/openid2/auth,OAuth2端点是/o/oauth2/auth。您需要将终端用户重定向到OAuth2端点,以告知(或“强制”)谷歌使用OAuth2。

票数 0
EN

Stack Overflow用户

发布于 2015-03-19 01:52:38

作者:https://github.com/3pillarlabs/socialauth/wiki/Sample-Properties

如果需要或需要传递额外参数,可以设置OAuth端点(RequestToken URL、授权URL和AccessToken URL

  • www.google.com.request_token_url
  • www.google.com.authentication_url
  • www.google.com.access_token_url
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15665050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档