Class: GoogleSpreadsheetFetcher::Authorizer::ServiceAccount
- Inherits:
-
Object
- Object
- GoogleSpreadsheetFetcher::Authorizer::ServiceAccount
- Includes:
- Interface
- Defined in:
- lib/google_spreadsheet_fetcher/authorizer/service_account.rb
Instance Method Summary collapse
- #fetch_credentials!(user_id: nil) ⇒ Object
-
#initialize(credential, scope: nil) ⇒ ServiceAccount
constructor
A new instance of ServiceAccount.
- #setup! ⇒ Object
Constructor Details
#initialize(credential, scope: nil) ⇒ ServiceAccount
Returns a new instance of ServiceAccount.
6 7 8 9 10 11 |
# File 'lib/google_spreadsheet_fetcher/authorizer/service_account.rb', line 6 def initialize(credential, scope: nil) @credential = credential @scope = scope || ::GoogleSpreadsheetFetcher.config.scopes freeze end |
Instance Method Details
#fetch_credentials!(user_id: nil) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/google_spreadsheet_fetcher/authorizer/service_account.rb', line 15 def fetch_credentials!(user_id: nil) ::Google::Auth::ServiceAccountCredentials.make_creds( json_key_io: StringIO.new(credential), scope: scope ).tap(&:fetch_access_token!) end |
#setup! ⇒ Object
13 |
# File 'lib/google_spreadsheet_fetcher/authorizer/service_account.rb', line 13 def setup!; end |