-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose the jwt-token method #116
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call. |
||
) | ||
token = @authorizer.fetch_access_token! | ||
token["access_token"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.