mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-10-04 01:00:44 -04:00
Update qbo.rb
This commit is contained in:
1 parent
4eb6c533f1
commit
fd383ad9d4
1 file changed
+5
-1
+5
-1
@@ -34,14 +34,18 @@ class Qbo < ActiveRecord::Base
|
|||||||
def self.get_base(type)
|
def self.get_base(type)
|
||||||
oauth2_client = get_client
|
oauth2_client = get_client
|
||||||
qbo = self.first
|
qbo = self.first
|
||||||
access_token = OAuth2::AccessToken.new(oauth2_client, qbo.qb_token , refresh_token: qbo.qb_secret)
|
#access_token = OAuth2::AccessToken.new(oauth2_client, qbo.qb_token , refresh_token: qbo.qb_secret)
|
||||||
|
|
||||||
|
# get our access token ready
|
||||||
if qbo.expire.to_date.past?
|
if qbo.expire.to_date.past?
|
||||||
|
access_token = OAuth2::AccessToken.new(oauth2_client, qbo.qb_token , refresh_token: qbo.qb_secret)
|
||||||
new_access_token_object = access_token.refresh!
|
new_access_token_object = access_token.refresh!
|
||||||
qbo.token = new_access_token_object
|
qbo.token = new_access_token_object
|
||||||
qbo.expire = 1.hour.from_now.utc
|
qbo.expire = 1.hour.from_now.utc
|
||||||
qbo.save!
|
qbo.save!
|
||||||
access_token = new_access_token_object
|
access_token = new_access_token_object
|
||||||
|
else
|
||||||
|
access_token = qbo.token
|
||||||
end
|
end
|
||||||
|
|
||||||
case type
|
case type
|
||||||
|
|||||||
Reference in new issue
Block a user