0

我想在我的网站上通过 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
4

1 回答 1

2

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

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
于 2013-06-21T07:58:35.770 回答