Class: CloudSQLRubyConnector::Credentials::Base
- Inherits:
-
Object
- Object
- CloudSQLRubyConnector::Credentials::Base
- Defined in:
- lib/cloud_sql_ruby_connector/credentials/base.rb
Overview
Base class for all credential types
Direct Known Subclasses
Constant Summary collapse
- SCOPES =
{ admin: "https://www.googleapis.com/auth/sqlservice.admin", login: "https://www.googleapis.com/auth/sqlservice.login" }.freeze
- TOKEN_URI =
"https://oauth2.googleapis.com/token"
Instance Method Summary collapse
-
#access_token(scope: :admin) ⇒ String
Get an access token for the specified scope.
-
#initialize ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
28 29 30 31 32 |
# File 'lib/cloud_sql_ruby_connector/credentials/base.rb', line 28 def initialize @tokens = {} @token_expiries = {} @mutex = Mutex.new end |
Instance Method Details
#access_token(scope: :admin) ⇒ String
Get an access token for the specified scope
37 38 39 40 41 42 |
# File 'lib/cloud_sql_ruby_connector/credentials/base.rb', line 37 def access_token(scope: :admin) @mutex.synchronize do refresh_token(scope) if token_expired?(scope) @tokens[scope] end end |