【问题标题】:SocialAuth - Facebook Authentication - Specify which access rights are requestedSocialAuth - Facebook 身份验证 - 指定请求的访问权限
【发布时间】:2013-06-18 00:05:48
【问题描述】:

我想在我的网站上通过 facebook 实现简单的登录。我为此使用了 SocialAuth,它工作得很好。但是,如果我通过 facebook 登录,则 facebook 应用程序需要确认很多访问权限,例如发布到墙上等等。

我不需要这些权利。我可以以某种方式定义请求哪些权限(基本上我不需要 - 只是登录)。这是我的代码:

//Create an instance of SocialAuthConfgi object
   SocialAuthConfig config = SocialAuthConfig.getDefault();

  //load configuration. By default load the configuration from oauth_consumer.properties. 
  //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 = "http://opensource.brickred.com/socialauthdemo/socialAuthSuccessAction.do";

  // 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(id, successUrl);

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

我的配置看起来像这样。我可以在这里以某种方式定义它吗?

#facebook
graph.facebook.com.consumer_key =   152190004803645
graph.facebook.com.consumer_secret = 64c94bd02180b0ade85889b44b2ba7c4
graph.facebook.com.secure = true
graph.facebook.com.request_token_url = /oauth/access_token
graph.facebook.com.authorization_url = /oauth/authorize
graph.facebook.com.access_token_url = /me
graph.facebook.com.signature_method = HMAC-SHA1
graph.facebook.com.transport_name = GET

【问题讨论】:

    标签: java facebook authentication oauth socialauth


    【解决方案1】:

    您可以像这样添加自定义权限。

    graph.facebook.com.consumer_key =   152190004803645
    graph.facebook.com.consumer_secret = 64c94bd02180b0ade85889b44b2ba7c4
    graph.facebook.com.custom_permission = email,user_birthday,user_location
    

    无需设置其他属性。但是如果你想设置其他属性,那么只有你可以设置request_token_url(对于OAuth1.0),authentication_url和access_token_url。此功能可从 socialauth-4.2 获得

    graph.facebook.com.authentication_url
    graph.facebook.com.access_token_url
    

    【讨论】:

    猜你喜欢
    • 2015-04-16
    • 2011-02-28
    • 1970-01-01
    • 2021-07-31
    • 2012-05-01
    • 2017-01-30
    • 2018-07-07
    • 2012-02-18
    • 1970-01-01
    相关资源
    最近更新 更多