2010-10-31 22 views
5

Khi bạn sử dụng OmniAuth để đăng nhập vào một ứng dụng web thông qua Facebook, đây là những điều khoản webapp có:Tôi làm cách nào để xác định quyền truy cập nào tôi cần từ tài khoản Facebook của người dùng khi sử dụng OmniAuth?

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 protected] 

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

Trong khi khi bạn sử dụng mini_fb đá quý để liên kết một ứng dụng web lên Facebook, đây là những điều khoản (phải xác định này dưới dạng mã khác định dạng được là lạ):

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 protected] · 

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 

tôi đang sử dụng OmniAuth vào lúc này, và muốn tiếp tục làm như vậy, nhưng ứng dụng của tôi cần được cấp thêm quyền, như một số trong những người bổ sung mà mini_fb có. Có ai biết làm thế nào tôi có thể tùy chỉnh OmniAuth để yêu cầu quyền bổ sung?

Trả lời

10

Bạn có thể kiểm tra tùy chọn sử dụng thuộc tính :scope:

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

Kiểm tra Facebook permissions documentation gì phạm vi bạn thực sự muốn và định nghĩa nó tách bởi một commant trên :scope tùy chọn.

Nếu bạn sử dụng một initializer để xác định OamniOauth của bạn, nó giống như rằng:

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

Cảm ơn câu trả lời của bạn, đó chính xác là những gì tôi cần. Xin lỗi được gây phiền nhiễu, nhưng chính xác thì tôi sẽ đặt dòng này ở đâu? – ben

+0

nơi bạn Đặt cấu hình của Facebook. – shingara

+0

Cảm ơn sự giúp đỡ của bạn! – ben

0

Nếu bạn đang sử dụng đưa ra (như tôi) là giải pháp đơn giản nhất là có cả hai 'devise' và 'omniauth-facebook' trong Gemfile của bạn. Sau đó, trong trình khởi tạo của bạn, bạn chỉ có thể thêm:

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

Điều này thực hiện rất tốt. Thêm trình khởi chạy omniauth với thiết lập được thiết lập

Các vấn đề liên quan