Module: Josef::GoogleWorkspace::Client

Includes:
Config, Group
Included in:
Cli, Remote
Defined in:
lib/josef/google_workspace/client.rb

Instance Method Summary collapse

Methods included from Group

#create_group, #delete_group, #groups, #groups!

Methods included from Members

#add_member, #del_member, #member_mail_addreses, #members_by

Methods included from Config

#actor, #actor!, #credential_path, #domains, #token_path

Instance Method Details

#authorize!Object



26
27
28
29
30
31
32
33
# File 'lib/josef/google_workspace/client.rb', line 26

def authorize!
  authorization = Google::Auth::ServiceAccountCredentials.make_creds(
    json_key_io: File.open(credential_path),
    scope: SCOPE)

  authorization.sub = actor
  authorization
end

#clientObject



14
15
16
# File 'lib/josef/google_workspace/client.rb', line 14

def client
  @_client ||= client!
end

#client!Object



18
19
20
21
22
23
24
# File 'lib/josef/google_workspace/client.rb', line 18

def client!
  service = Google::Apis::AdminDirectoryV1::DirectoryService.new
  service.authorization = authorize!
  service.authorization.fetch_access_token!

  service
end