geoloqi 0.9.11 → 0.9.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/geoloqi/session.rb +8 -17
- data/lib/geoloqi/version.rb +1 -1
- data/spec/geoloqi_spec.rb +2 -2
- metadata +2 -2
data/lib/geoloqi/session.rb
CHANGED
@@ -69,12 +69,10 @@ module Geoloqi
|
|
69
69
|
@config.use_hashie_mash ? Hashie::Mash.new(hash) : hash
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def establish(opts={})
|
73
73
|
require 'client_id and client_secret are required to get access token' unless @config.client_id? && @config.client_secret?
|
74
|
-
auth = post 'oauth/token', :client_id => @config.client_id,
|
75
|
-
|
76
|
-
:grant_type => 'refresh_token',
|
77
|
-
:refresh_token => self.auth[:refresh_token]
|
74
|
+
auth = post 'oauth/token', {:client_id => @config.client_id,
|
75
|
+
:client_secret => @config.client_secret}.merge!(opts)
|
78
76
|
|
79
77
|
# expires_at is likely incorrect. I'm chopping 5 seconds
|
80
78
|
# off to allow for a more graceful failover.
|
@@ -83,19 +81,12 @@ module Geoloqi
|
|
83
81
|
self.auth
|
84
82
|
end
|
85
83
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
:client_secret => @config.client_secret,
|
90
|
-
:code => code,
|
91
|
-
:grant_type => 'authorization_code',
|
92
|
-
:redirect_uri => redirect_uri
|
84
|
+
def renew_access_token!
|
85
|
+
establish :grant_type => 'refresh_token', :refresh_token => self.auth[:refresh_token]
|
86
|
+
end
|
93
87
|
|
94
|
-
|
95
|
-
|
96
|
-
auth['expires_at'] = auth_expires_at auth['expires_in']
|
97
|
-
self.auth = auth
|
98
|
-
self.auth
|
88
|
+
def get_auth(code, redirect_uri=@config.redirect_uri)
|
89
|
+
establish :grant_type => 'authorization_code', :code => code, :redirect_uri => redirect_uri
|
99
90
|
end
|
100
91
|
|
101
92
|
private
|
data/lib/geoloqi/version.rb
CHANGED
data/spec/geoloqi_spec.rb
CHANGED
@@ -266,8 +266,8 @@ include WebMock::API
|
|
266
266
|
stub_request(:post, "https://api.geoloqi.com/1/oauth/token").
|
267
267
|
with(:body => {:client_id => ARGV[0],
|
268
268
|
:client_secret => ARGV[1],
|
269
|
-
:code => "1234",
|
270
269
|
:grant_type => "authorization_code",
|
270
|
+
:code => "1234",
|
271
271
|
:redirect_uri => "http://neverexpires.example.com/"}.to_json).
|
272
272
|
to_return(:status => 200,
|
273
273
|
:body => {:access_token => 'access_token1234',
|
@@ -278,8 +278,8 @@ stub_request(:post, "https://api.geoloqi.com/1/oauth/token").
|
|
278
278
|
stub_request(:post, "https://api.geoloqi.com/1/oauth/token").
|
279
279
|
with(:body => {:client_id => ARGV[0],
|
280
280
|
:client_secret => ARGV[1],
|
281
|
-
:code => "1234",
|
282
281
|
:grant_type => "authorization_code",
|
282
|
+
:code => "1234",
|
283
283
|
:redirect_uri => "http://test.site/"}.to_json).
|
284
284
|
to_return(:status => 200,
|
285
285
|
:body => {:access_token => 'access_token1234',
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: geoloqi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.12
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kyle Drake
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-07-
|
14
|
+
date: 2011-07-08 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|