2 Commits

Author SHA1 Message Date
9779437c00 Log token refresh 2024-12-19 09:41:53 -05:00
1a37926628 Log error not info 2024-12-19 09:36:23 -05:00

View File

@@ -21,7 +21,7 @@ module QuickbooksOauth
begin begin
yield oauth_access_token yield oauth_access_token
rescue OAuth2::Error, Quickbooks::AuthorizationFailure => ex rescue OAuth2::Error, Quickbooks::AuthorizationFailure => ex
Rails.logger.info("QuickbooksOauth.perform: #{ex.message}") Rails.logger.error("QuickbooksOauth.perform: #{ex.message}")
# to prevent an infinite loop here keep a counter and bail out after N times... # to prevent an infinite loop here keep a counter and bail out after N times...
attempts += 1 attempts += 1
@@ -36,6 +36,7 @@ module QuickbooksOauth
end end
def refresh_token! def refresh_token!
Rails.logger.info("QuickbooksOauth.refresh_token!")
t = oauth_access_token t = oauth_access_token
refreshed = t.refresh! refreshed = t.refresh!
@@ -45,6 +46,8 @@ module QuickbooksOauth
oauth2_refresh_token_expires_at = 100.days.from_now oauth2_refresh_token_expires_at = 100.days.from_now
end end
Rails.logger.info("QuickbooksOauth.refresh_token!: #{oauth2_refresh_token_expires_at}")
update!( update!(
oauth2_access_token: refreshed.token, oauth2_access_token: refreshed.token,
oauth2_access_token_expires_at: Time.at(refreshed.expires_at), oauth2_access_token_expires_at: Time.at(refreshed.expires_at),