Class: Utcp::Auth::OAuth2
Instance Method Summary collapse
- #apply_headers(h) ⇒ Object
-
#initialize(token_url:, client_id:, client_secret:, scope: nil) ⇒ OAuth2
constructor
A new instance of OAuth2.
Methods inherited from Base
Constructor Details
#initialize(token_url:, client_id:, client_secret:, scope: nil) ⇒ OAuth2
55 56 57 58 59 60 61 62 |
# File 'lib/utcp/auth.rb', line 55 def initialize(token_url:, client_id:, client_secret:, scope: nil) @token_url = Utils::Subst.apply(token_url) @client_id = Utils::Subst.apply(client_id) @client_secret = Utils::Subst.apply(client_secret) @scope = scope && Utils::Subst.apply(scope) @cached = nil @expires_at = Time.at(0) end |
Instance Method Details
#apply_headers(h) ⇒ Object
64 65 66 67 68 |
# File 'lib/utcp/auth.rb', line 64 def apply_headers(h) token = fetch_token h["Authorization"] = "Bearer #{token}" h end |