Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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