class Pushr::Daemon::FcmSupport::Authenticator
Constants
- SCOPE
Attributes
configuration[R]
Public Class Methods
new(configuration, i)
click to toggle source
# File lib/pushr/daemon/fcm_support/authenticator.rb, line 18 def initialize(configuration, i) @configuration = configuration @name = "#{@configuration.app}: AuthenticatorFcm #{i}" end
Public Instance Methods
fetch_access_token()
click to toggle source
# File lib/pushr/daemon/fcm_support/authenticator.rb, line 23 def fetch_access_token if @response.nil? || (@request_at + @response['expires_in'] < Time.now) Pushr::Daemon.logger.info("[#{@name}] Refresh access token") authorizer = fetch_credentials @request_at = Time.now @response = authorizer.fetch_access_token! end puts @response['access_token'].inspect @response['access_token'] end
Private Instance Methods
fetch_credentials()
click to toggle source
# File lib/pushr/daemon/fcm_support/authenticator.rb, line 36 def fetch_credentials ::Google::Auth::ServiceAccountCredentials.make_creds(json_key_io: JsonReader.new(@configuration), scope: SCOPE) # authorizer = Google::Auth::ServiceAccountCredentials.make_creds(json_key_io: File.open('/Users/tom/Downloads/api-7505019477374111882-459984-firebase-adminsdk-o569m-8d9bc31fb7.json'), scope: scope) end