Class: GoogleOAuthCli

Inherits:
Object
  • Object
show all
Defined in:
lib/google-oauth-cli.rb,
lib/google-oauth-cli/server.rb,
lib/google-oauth-cli/version.rb

Defined Under Namespace

Classes: Error, Server

Constant Summary collapse

VERSION =
"1.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, client_secret:, scope:, credentials_file: nil, port: 9876) ⇒ GoogleOAuthCli

Returns a new instance of GoogleOAuthCli.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/google-oauth-cli.rb', line 11

def initialize(client_id:, client_secret:, scope:, credentials_file: nil, port: 9876)
  @credentials = Google::Auth::UserRefreshCredentials.new(
    client_id: client_id,
    client_secret: client_secret,
    scope: scope,
    redirect_uri: "http://localhost:#{port}/authorize",
    additional_parameters: { access_type: "offline" }
  )
  if credentials_file
    @credentials_file = Pathname.new(File.expand_path(credentials_file))
    @credentials_file
  end
  @port = port
end

Instance Method Details

#loginObject



26
27
28
# File 'lib/google-oauth-cli.rb', line 26

def 
  authorize_from_credentials || authorize_from_authorization_code_flow
end