使用OmniAuth时,如何指定用户的Facebook帐户需要哪些访问权限?

时间:2010-10-31 06:18:28

标签: ruby-on-rails facebook facebook-graph-api omniauth

当您使用OmniAuth通过Facebook登录网络应用时,这些是网络应用的权限:

Access my basic information Includes name, profile picture, gender, networks, user ID, list of friends, and any other information I've shared with everyone.

Send me email WebApp may email me directly at email@email.com

Access my data any time WebApp may access my data when I'm not using the application

当您使用mini_fb gem将Web应用程序链接到Facebook时,这些是权限(必须将其指定为代码,否则格式化很奇怪):

Access my basic information
Includes name, profile picture, gender, networks, user ID, list of friends, and any other information I've shared with everyone.

Required
Send me email
WebApp may email me directly at email@email.com ·

Required
Access my profile information
Likes, Music, TV, Movies, Books, Quotes, About Me, Activitie...s, Interests, Groups, Events, Notes, Birthday, Hometown, Current City, Website, Religious and Political Views, Education History, Work History and Facebook StatusSee More

Required
Online Presence

Required
Access my family & relationships
Family Members and Relationship Status

Required
Access my photos and videos
Photos Uploaded by Me, Videos Uploaded by Me and Photos and Videos of Me

Required
Access my friends' information
Birthdays, Religious and Political Views, Family Members and... Relationship Statuses, Hometowns, Current Cities, Likes, Music, TV, Movies, Books, Quotes, Activities, Interests, Education History, Work History, Online Presence, Websites, Groups, Events, Notes, Photos, Videos, Photos and Videos of Them, 'About Me' Details and Facebook StatusesSee More

Required
Post to my Wall
WebApp may post status messages, notes, photos, and videos to my Wall

Access messages in my inbox

Access posts in my News Feed

Access my data any time
WebApp may access my data when I'm not using the application

Access Facebook Chat

Send me SMS messages
WebApp may send SMS messages to my phone:

Manage my events
WebApp may create and RSVP to events on my behalf

Access my custom friend lists

Access my friend requests

Insights
WebApp may access Insights data for my pages and applications

Manage my advertisements

我目前正在使用OmniAuth,并希望继续这样做,但我的应用需要更多权限,就像mini_fb所拥有的一些额外权限一样。有谁知道如何自定义OmniAuth以请求额外的权限?

2 个答案:

答案 0 :(得分:10)

您可以使用:scope属性检查选项:

use OmniAuth::Strategies::Facebook, 'app_id', 'app_secret', {:scope => 'email,offline_access, your,scope,you,want'}

检查Facebook permissions documentation您真正想要的范围,并通过:scope选项上的commant单独定义。

如果你使用初始化程序来定义你的OamniOauth,那就是:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, 'APP_ID', 'APP_SECRET', {:scope => 'email,offline_access, your,scope,you,want'}
end

答案 1 :(得分:0)

如果你正在使用设计(像我一样),最简单的解决方案是在你的Gemfile中同时拥有'devise'和'omniauth-facebook'。然后在您的设计初始化程序中,您只需添加:

config.omniauth :facebook, "app", "secret", :scope => "user_photos"

这很好用。使用设计设置添加omniauth初始化程序