Class: Lt::Google::Api::Auth::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/lt/google/api/auth/cli.rb

Constant Summary collapse

CONFIG_SECRET_FILE =
Rails.root.join('config', 'google', 'client_secret.json')
CONFIG_TOKEN_FILE =
Rails.root.join('config', 'google', 'app_token.yaml')
SCOPE =
%w(https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/documents).freeze
USER_ID =
'default'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authorizerObject



16
17
18
19
20
21
22
# File 'lib/lt/google/api/auth/cli.rb', line 16

def self.authorizer
  @authorizer ||= begin
    client_id = ::Google::Auth::ClientId.from_file(CONFIG_SECRET_FILE)
    token_store = ::Google::Auth::Stores::FileTokenStore.new(file: CONFIG_TOKEN_FILE)
    ::Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)
  end
end

Instance Method Details

#authorizerObject



24
25
26
# File 'lib/lt/google/api/auth/cli.rb', line 24

def authorizer
  self.class.authorizer
end

#credentialsObject



28
29
30
# File 'lib/lt/google/api/auth/cli.rb', line 28

def credentials
  @credentials ||= authorizer.get_credentials(USER_ID)
end