geoloqi 0.9.33 → 0.9.35
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.yardopts +3 -0
- data/{license.txt → LICENSE.md} +0 -0
- data/README.md +111 -0
- data/examples/simple.rb +10 -10
- data/examples/sinatra_simple.rb +19 -0
- data/examples/sinatra_synchrony.rb +16 -24
- data/geoloqi.gemspec +3 -2
- data/lib/geoloqi.rb +45 -2
- data/lib/geoloqi/config.rb +7 -1
- data/lib/geoloqi/data/ca-certificates.crt +3376 -0
- data/lib/geoloqi/session.rb +73 -7
- data/lib/geoloqi/version.rb +4 -1
- data/spec/env.rb +1 -1
- data/spec/geoloqi_config.rb +1 -1
- data/spec/geoloqi_session_spec.rb +21 -20
- data/spec/geoloqi_spec.rb +2 -2
- metadata +23 -11
- data/README.markdown +0 -158
- data/examples/sinatra.rb +0 -30
data/examples/sinatra.rb
DELETED
@@ -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
|