Created
November 28, 2011 01:55
-
-
Save petewarden/1398770 to your computer and use it in GitHub Desktop.
Asking for extra permissions dynamically with OmniAuth in Sinatra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is called before the external site, so we can add dynamic Facebook permissions | |
# for example. See http://www.mikepackdev.com/blog_posts/2-dynamically-requesting-facebook-permissions-with-omniauth | |
get '/auth/:name/setup' do | |
if session[:extra_permissions] | |
request.env['omniauth.strategy'].options[:scope] = STANDARD_FACEBOOK_PERMISSIONS+','+session[:extra_permissions] | |
session.delete(:extra_permissions) | |
end | |
# This looks odd, but is the expected way to indicate success to Omniauth! | |
halt 404, 'Setup complete' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment