Class: GoogleService
- Inherits:
-
Object
- Object
- GoogleService
- Defined in:
- app/services/google_service.rb
Instance Method Summary collapse
- #access_token ⇒ Object
-
#initialize ⇒ GoogleService
constructor
A new instance of GoogleService.
Constructor Details
#initialize ⇒ GoogleService
Returns a new instance of GoogleService.
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. = service_account. end |
Instance Method Details
#access_token ⇒ Object
20 21 22 23 |
# File 'app/services/google_service.rb', line 20 def access_token response = @client..fetch_access_token! response["access_token"] end |