0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

added code to handle token refresh jobs specific to services

Dieser Commit ist enthalten in:
Robert Barrow 2019-05-19 14:56:17 +01:00
Ursprung 3aeb6a3b47
Commit 52b8c229ba
2 geänderte Dateien mit 8 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,7 @@
module Jobs module Jobs
class RefreshAPIAccessToken < Jobs::Base class RefreshApiAccessToken < Jobs::Base
def execute(args) def execute(args)
CustomWizard::Authorization.refresh_access_token CustomWizard::Authorization.refresh_access_token(args[:service])
end end
end end
end end

Datei anzeigen

@ -121,7 +121,7 @@ class CustomWizard::Authorization
def self.refresh_access_token(service) def self.refresh_access_token(service)
body = { body = {
grant_type: 'refresh_token', grant_type: 'refresh_token',
refresh_token: CustomWizard::Authorization.refresh_token refresh_token: CustomWizard::Authorization.refresh_token(service)
} }
authorization_string = CustomWizard::Authorization.client_id(service) + ':' + CustomWizard::Authorization.client_secret(service) authorization_string = CustomWizard::Authorization.client_id(service) + ':' + CustomWizard::Authorization.client_secret(service)
@ -146,7 +146,11 @@ class CustomWizard::Authorization
expires_at = Time.now + data['expires_in'].seconds expires_at = Time.now + data['expires_in'].seconds
refresh_at = expires_at.to_time - 2.hours refresh_at = expires_at.to_time - 2.hours
Jobs.enqueue_at(refresh_at, :refresh_api_access_token) opts = {
service: service
}
Jobs.enqueue_at(refresh_at, :refresh_api_access_token, opts)
CustomWizard::Authorization.set_access_token( CustomWizard::Authorization.set_access_token(
service: service, service: service,