4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/services/google_service.rb', line 4
def initialize
name = Rails.application.class.to_s
version = "1"
issuer = Rails.application.secrets.ga_client_email
key_path = Rails.root.join("config", "google_service_key.p12").to_s
passphrase = Rails.application.secrets.ga_passphrase
scope = ["https://www.googleapis.com/auth/analytics.readonly"]
@client = Google::APIClient.new(application_name: name,
application_version: version)
key = Google::APIClient::PKCS12.load_key(key_path, passphrase)
service_account = Google::APIClient::JWTAsserter.new(issuer, scope, key)
@client.authorization = service_account.authorize
end
|