Created
September 21, 2018 11:29
-
-
Save AbigailMcP/42337f0f5f08f2fb782c0d2a6801a734 to your computer and use it in GitHub Desktop.
Google Analytics Reporting service authorization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a Google Analytics Reporting service | |
service = Google::Apis::AnalyticsreportingV4::AnalyticsReportingService.new | |
# Create service account credentials | |
credentials = Google::Auth::ServiceAccountCredentials.make_creds( | |
json_key_io: File.open('path/to/service_account_cred.json'), | |
scope: 'https://www.googleapis.com/auth/analytics.readonly' | |
) | |
# Authorize with our readonly credentials | |
service.authorization = credentials | |
$google_client = service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment