Class: Pushr::Daemon::FcmSupport::Authenticator
- Inherits:
-
Object
- Object
- Pushr::Daemon::FcmSupport::Authenticator
- Defined in:
- lib/pushr/daemon/fcm_support/authenticator.rb
Constant Summary collapse
- SCOPE =
'https://www.googleapis.com/auth/firebase.messaging'.freeze
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #fetch_access_token ⇒ Object
-
#initialize(configuration, i) ⇒ Authenticator
constructor
A new instance of Authenticator.
Constructor Details
#initialize(configuration, i) ⇒ Authenticator
Returns a new instance of Authenticator.
18 19 20 21 |
# File 'lib/pushr/daemon/fcm_support/authenticator.rb', line 18 def initialize(configuration, i) @configuration = configuration @name = "#{@configuration.app}: AuthenticatorFcm #{i}" end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
15 16 17 |
# File 'lib/pushr/daemon/fcm_support/authenticator.rb', line 15 def configuration @configuration end |
Instance Method Details
#fetch_access_token ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# 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") = fetch_credentials @request_at = Time.now @response = .fetch_access_token! end puts @response['access_token'].inspect @response['access_token'] end |