class FirebaseCloudMessenger::AuthClient
Constants
- AUTH_SCOPE
Attributes
credentials_path[R]
Public Class Methods
new(credentials_path = nil)
click to toggle source
# File lib/firebase_cloud_messenger/auth_client.rb, line 9 def initialize(credentials_path = nil) @credentials_path = credentials_path raise_credentials_not_supplied if !credentials_supplied? @authorizer = Google::Auth::ServiceAccountCredentials.make_creds(cred_args) end
Public Instance Methods
fetch_access_token_info()
click to toggle source
# File lib/firebase_cloud_messenger/auth_client.rb, line 17 def fetch_access_token_info authorizer.fetch_access_token! rescue Faraday::ConnectionFailed raise ConnectTimeout rescue Faraday::TimeoutError raise ReadTimeout end
Private Instance Methods
cred_args()
click to toggle source
# File lib/firebase_cloud_messenger/auth_client.rb, line 40 def cred_args args = { scope: AUTH_SCOPE } return args unless credentials_path file = Pathname.new(credentials_path) args.merge(json_key_io: file) end
credentials_supplied?()
click to toggle source
# File lib/firebase_cloud_messenger/auth_client.rb, line 29 def credentials_supplied? credentials_path || (ENV['GOOGLE_CLIENT_EMAIL'] && ENV['GOOGLE_PRIVATE_KEY']) end
raise_credentials_not_supplied()
click to toggle source
# File lib/firebase_cloud_messenger/auth_client.rb, line 33 def raise_credentials_not_supplied msg = "Either a path to a service account credentials json must be supplied, "\ "or the `GOOGLE_CLIENT_EMAIL` and `GOOGLE_PRIVATE_KEY` env vars must be set." raise ArgumentError, msg end