Skip to content

Instantly share code, notes, and snippets.

@petewarden
Created November 28, 2011 01:55
Show Gist options
  • Save petewarden/1398770 to your computer and use it in GitHub Desktop.
Save petewarden/1398770 to your computer and use it in GitHub Desktop.
Asking for extra permissions dynamically with OmniAuth in Sinatra
# 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