diff --git a/lib/fcm.rb b/lib/fcm.rb index 08980ce..eead637 100644 --- a/lib/fcm.rb +++ b/lib/fcm.rb @@ -217,6 +217,16 @@ def send_to_topic_condition(condition, options = {}) end end + def jwt_token + scope = "https://www.googleapis.com/auth/firebase.messaging" + @authorizer ||= Google::Auth::ServiceAccountCredentials.make_creds( + json_key_io: json_key, + scope: scope, + ) + token = @authorizer.fetch_access_token! + token["access_token"] + end + private def for_uri(uri, extra_headers = {}) @@ -316,16 +326,6 @@ def validate_condition_topics?(condition) topics.all? { |topic| topic.gsub(TOPIC_REGEX, "").length == 0 } end - def jwt_token - scope = "https://www.googleapis.com/auth/firebase.messaging" - @authorizer ||= Google::Auth::ServiceAccountCredentials.make_creds( - json_key_io: json_key, - scope: scope, - ) - token = @authorizer.fetch_access_token! - token["access_token"] - end - def json_key @json_key ||= if @json_key_path.respond_to?(:read) @json_key_path