Class: Arquivo::C118sheets
- Inherits:
-
Object
- Object
- Arquivo::C118sheets
- Defined in:
- lib/arquivo/sheets.rb
Overview
acede a folhas-calculo c118
Direct Known Subclasses
Instance Attribute Summary collapse
-
#folhas ⇒ Google::Apis::SheetsV4::SheetsService
readonly
API folhas-calculo c118.
Instance Method Summary collapse
-
#initialize ⇒ C118sheets
constructor
Acesso folhas-calculo c118.
-
#new_credentials(aut, oob) ⇒ Google::Auth::UserAuthorizer
inicializar OAuth2 authorization abrindo URL e copiando novo codigo.
-
#sheets_credentials ⇒ Google::Apis::SheetsV4::SheetsService
inicializar API sheets com ID cliente & credenciais.
Constructor Details
#initialize ⇒ C118sheets
Returns acesso folhas-calculo c118.
14 15 16 |
# File 'lib/arquivo/sheets.rb', line 14 def initialize sheets_credentials end |
Instance Attribute Details
#folhas ⇒ Google::Apis::SheetsV4::SheetsService (readonly)
Returns API folhas-calculo c118.
11 12 13 |
# File 'lib/arquivo/sheets.rb', line 11 def folhas @folhas end |
Instance Method Details
#new_credentials(aut, oob) ⇒ Google::Auth::UserAuthorizer
inicializar OAuth2 authorization abrindo URL e copiando novo codigo
37 38 39 40 |
# File 'lib/arquivo/sheets.rb', line 37 def new_credentials(aut, oob) puts 'Open URL and copy code after authorization, in <codigo-aqui>', aut.(base_url: oob) aut.get_and_store_credentials_from_code(user_id: 'default', code: '<codigo-aqui>', base_url: oob) end |
#sheets_credentials ⇒ Google::Apis::SheetsV4::SheetsService
inicializar API sheets com ID cliente & credenciais
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/arquivo/sheets.rb', line 21 def sheets_credentials l = '/home/c118/.sheets.' # file obtido console.cloud.google.com/apis OAuth 2.0 client IDs i = Google::Auth::ClientId.from_file(l + 'json') s = Google::Apis::SheetsV4::AUTH_SPREADSHEETS_READONLY # file criado aquando new_credentials is executed f = Google::Auth::Stores::FileTokenStore.new(file: l + 'yaml') z = Google::Auth::UserAuthorizer.new(i, s, f) @folhas = Google::Apis::SheetsV4::SheetsService.new @folhas..application_name = 'c118-arquivo' @folhas. = z.get_credentials('default') || new_credentials(z, 'urn:ietf:wg:oauth:2.0:oob') end |