Class: Purple::Requests::Authorization
- Inherits:
-
Object
- Object
- Purple::Requests::Authorization
- Defined in:
- lib/purple/requests/authorization.rb
Class Method Summary collapse
- .bearer_token(value) ⇒ Object
- .custom_headers(headers) ⇒ Object
- .custom_query(headers) ⇒ Object
- .google_auth(credentials:, product:) ⇒ Object
Class Method Details
.bearer_token(value) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/purple/requests/authorization.rb', line 7 def bearer_token(value) { type: :bearer, data: lambda do { Authorization: "Bearer #{value}" } end } end |
.custom_headers(headers) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/purple/requests/authorization.rb', line 36 def custom_headers(headers) { type: :custom_headers, data: lambda do headers end } end |
.custom_query(headers) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/purple/requests/authorization.rb', line 45 def custom_query(headers) { type: :custom_query, data: lambda do headers end } end |
.google_auth(credentials:, product:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/purple/requests/authorization.rb', line 16 def google_auth(credentials:, product:) auth_scope = case product when :firebase 'firebase.messaging' end { type: :google_auth, data: lambda do = Google::Auth::ServiceAccountCredentials.make_creds( json_key_io: StringIO.new(credentials), scope: "https://www.googleapis.com/auth/#{auth_scope}" ) access_token = .fetch_access_token! bearer_token access_token['access_token'] end } end |