Load oauth key & secret when constructing client, not on application start up

This commit is contained in:
2025-06-16 22:16:58 -04:00
parent 60857e9dca
commit 43c7374c42

View File

@@ -1,6 +1,6 @@
#The MIT License (MIT) #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: #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 module QuickbooksOauth
extend ActiveSupport::Concern extend ActiveSupport::Concern
OAUTH_CONSUMER_KEY = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey']
OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret']
#== Instance Methods #== Instance Methods
def perform_authenticated_request(&block) def perform_authenticated_request(&block)
@@ -71,12 +68,16 @@ module QuickbooksOauth
module ClassMethods module ClassMethods
def construct_oauth2_client def construct_oauth2_client
oauth_consumer_key = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey']
oauth_consumer_secret = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret']
options = { options = {
site: "https://appcenter.intuit.com/connect/oauth2", site: "https://appcenter.intuit.com/connect/oauth2",
authorize_url: "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" 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
end end