Class: Flycal::Credentials
- Inherits:
-
Object
- Object
- Flycal::Credentials
- Defined in:
- lib/flycal/credentials.rb
Overview
Builds Google auth credentials from externally supplied tokens (Rails OAuth session, CLI token store, etc.).
Constant Summary collapse
- DEFAULT_SCOPE =
"https://www.googleapis.com/auth/calendar.readonly"
Class Method Summary collapse
- .from_tokens(access_token:, refresh_token: nil, client_id:, client_secret:, expires_at: nil, scope: DEFAULT_SCOPE) ⇒ Object
- .wrap(credentials) ⇒ Object
Class Method Details
.from_tokens(access_token:, refresh_token: nil, client_id:, client_secret:, expires_at: nil, scope: DEFAULT_SCOPE) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flycal/credentials.rb', line 11 def self.from_tokens( access_token:, refresh_token: nil, client_id:, client_secret:, expires_at: nil, scope: DEFAULT_SCOPE ) opts = { client_id: client_id, client_secret: client_secret, scope: scope, access_token: access_token, refresh_token: refresh_token } opts[:expires_at] = expires_at.to_i if expires_at Google::Auth::UserRefreshCredentials.new(**opts) end |
.wrap(credentials) ⇒ Object
30 31 32 |
# File 'lib/flycal/credentials.rb', line 30 def self.wrap(credentials) credentials end |