Class: Google::ServiceAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/google/service_account.rb

Constant Summary collapse

CLIENT_ID_SUFFIX =
".apps.googleusercontent.com"
CLIENT_EMAIL_DOMAIN =
"developer.gserviceaccount.com"
ACCOUNTS_GOOGLE_COM_BASE_URI =
"https://accounts.google.com"
WWW_GOOGLEAPIS_COM_BASE_URI =
"https://www.googleapis.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id) ⇒ ServiceAccount

Returns a new instance of ServiceAccount.



14
15
16
17
18
19
20
21
22
23
# File 'lib/google/service_account.rb', line 14

def initialize(client_id)
  @id = client_id.include?(CLIENT_ID_SUFFIX) ? scan_id(client_id) : client_id
  @auth_uri                    = ACCOUNTS_GOOGLE_COM_BASE_URI + "/o/oauth2/auth"
  @token_uri                   = ACCOUNTS_GOOGLE_COM_BASE_URI + "/o/oauth2/token"
  @client_id                   = @id + CLIENT_ID_SUFFIX
  @client_email                = @id + "@" + CLIENT_EMAIL_DOMAIN
  @auth_provider_x509_cert_url = WWW_GOOGLEAPIS_COM_BASE_URI  + "/oauth2/v1/certs"
  @client_x509_cert_url        = WWW_GOOGLEAPIS_COM_BASE_URI  + "/robot/v1/metadata/x509" + @client_email
  @scope                       = WWW_GOOGLEAPIS_COM_BASE_URI  + "/auth/calendar"
end

Instance Attribute Details

#auth_provider_x509_cert_urlObject (readonly)

Returns the value of attribute auth_provider_x509_cert_url.



11
12
13
# File 'lib/google/service_account.rb', line 11

def auth_provider_x509_cert_url
  @auth_provider_x509_cert_url
end

#auth_uriObject (readonly)

Returns the value of attribute auth_uri.



9
10
11
# File 'lib/google/service_account.rb', line 9

def auth_uri
  @auth_uri
end

#client_emailObject (readonly)

Returns the value of attribute client_email.



10
11
12
# File 'lib/google/service_account.rb', line 10

def client_email
  @client_email
end

#client_idObject (readonly)

Returns the value of attribute client_id.



10
11
12
# File 'lib/google/service_account.rb', line 10

def client_id
  @client_id
end

#client_x509_cert_urlObject (readonly)

Returns the value of attribute client_x509_cert_url.



11
12
13
# File 'lib/google/service_account.rb', line 11

def client_x509_cert_url
  @client_x509_cert_url
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/google/service_account.rb', line 8

def id
  @id
end

#scopeObject (readonly)

Returns the value of attribute scope.



12
13
14
# File 'lib/google/service_account.rb', line 12

def scope
  @scope
end

#token_uriObject (readonly)

Returns the value of attribute token_uri.



9
10
11
# File 'lib/google/service_account.rb', line 9

def token_uri
  @token_uri
end