From 43c7374c42ff8d76b70b3040abd1392d39e36044 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 16 Jun 2025 22:16:58 -0400 Subject: [PATCH] Load oauth key & secret when constructing client, not on application start up --- app/models/concerns/quickbooks_oauth.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/quickbooks_oauth.rb b/app/models/concerns/quickbooks_oauth.rb index 3892780..d99344d 100644 --- a/app/models/concerns/quickbooks_oauth.rb +++ b/app/models/concerns/quickbooks_oauth.rb @@ -1,6 +1,6 @@ #The MIT License (MIT) # -#Copyright (c) 2023 rick barrette +#Copyright (c) 2016 - 2025 rick barrette # #Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: # @@ -11,9 +11,6 @@ module QuickbooksOauth extend ActiveSupport::Concern - OAUTH_CONSUMER_KEY = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey'] - OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret'] - #== Instance Methods def perform_authenticated_request(&block) @@ -71,12 +68,16 @@ module QuickbooksOauth module ClassMethods def construct_oauth2_client + + oauth_consumer_key = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey'] + oauth_consumer_secret = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret'] + options = { site: "https://appcenter.intuit.com/connect/oauth2", authorize_url: "https://appcenter.intuit.com/connect/oauth2", token_url: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer" } - OAuth2::Client.new(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, options) + OAuth2::Client.new(oauth_consumer_key, oauth_consumer_secret, options) end end