geoloqi 0.9.33 → 0.9.35

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +0,0 @@
1
- # A simple Sinatra example demonstrating OAuth2 implementation with Geoloqi
2
-
3
- require 'rubygems'
4
- require 'sinatra'
5
- require 'geoloqi'
6
-
7
- GEOLOQI_REDIRECT_URI = 'http://yourwebsite.net'
8
-
9
- enable :sessions
10
- set :session_secret, 'PUT A SECRET WORD HERE' # Encrypts the cookie session.. recommended.
11
-
12
- def geoloqi
13
- @geoloqi ||= Geoloqi::Session.new :auth => session[:geoloqi_auth],
14
- :config => {:client_id => 'YOUR OAUTH CLIENT ID',
15
- :client_secret => 'YOUR CLIENT SECRET'}
16
- end
17
-
18
- # If the access token expires, Geoloqi::Session will refresh inline!
19
- # This after block makes sure the session gets the updated config.
20
- after do
21
- session[:geoloqi_auth] = @geoloqi.auth
22
- end
23
-
24
- get '/?' do
25
- geoloqi.get_auth(params[:code], GEOLOQI_REDIRECT_URI) if params[:code] && !geoloqi.access_token?
26
- redirect geoloqi.authorize_url(GEOLOQI_REDIRECT_URI) unless geoloqi.access_token?
27
-
28
- username = geoloqi.get('account/username')['username']
29
- "You have successfully logged in as #{username}!"
30
- end