Skip to content

Instantly share code, notes, and snippets.

@amitsaxena
Created October 20, 2011 01:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitsaxena/1300167 to your computer and use it in GitHub Desktop.
Save amitsaxena/1300167 to your computer and use it in GitHub Desktop.
def url_for_oauth_code(options = {})
# for permissions, see http://developers.facebook.com/docs/authentication/permissions
permissions = options[:permissions]
scope = permissions ? "&scope=#{permissions.is_a?(Array) ? permissions.join(",") : permissions}" : ""
display = options.has_key?(:display) ? "&display=#{options[:display]}" : ""
callback = options[:callback] || @oauth_callback_url
raise ArgumentError, "url_for_oauth_code must get a callback either from the OAuth object or in the options!" unless callback
# Creates the URL for oauth authorization for a given callback and optional set of permissions
"https://#{GRAPH_SERVER}/oauth/authorize?client_id=#{@app_id}&redirect_uri=#{callback}#{scope}#{display}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment