Skip to content

Instantly share code, notes, and snippets.

@kyledrake
Created June 3, 2011 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyledrake/1007336 to your computer and use it in GitHub Desktop.
Save kyledrake/1007336 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'geoloqi'
GEOLOQI_REDIRECT_URI = 'http://yourwebsite.net'
enable :sessions
configure do
Geoloqi.config :client_id => 'YOUR OAUTH CLIENT ID', :client_secret => 'YOUR CLIENT SECRET'
end
def geoloqi
@geoloqi ||= Geoloqi::Session.new :auth => session[:geoloqi_auth]
end
get '/?' do
# session[:geoloqi_auth] = geoloqi.get_auth(params[:code], GEOLOQI_REDIRECT_URI) if params[:code] && !geoloqi.access_token?
redirect geoloqi.authorize_url(GEOLOQI_REDIRECT_URI) unless geoloqi.access_token?
username = geoloqi.get('account/username')['username']
"You have successfully logged in as #{username}!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment