Google 分析 API 和 Rails

Google Analytics API and Rails

我正在使用 google-api-client-0.8.2Rails 4.2.3。我使用的服务代码是 http://www.slatestudio.com/blog/p/how-to-pull-google-analytics-data-from-rails-app 处的代码。环境变量都已设置,我正在从

获取环境变量
# these from https://www.google.com/analytics/
GA_VIEW_ID: Admin > Select Site > View Tab > View Settings 
GA_APP_NAME: Home > name of folder with code in parenthesis

# these from https://console.developers.google.com/
GA_SERVICE_ACCOUNT_EMAIL: Project > API > Credentials > 123@developer.gserviceaccount.com
GA_KEY_FILE_NAME: Same path above > P12 Key

我也变了

service_account = Google::APIClient::JWTAsserter.new(
  ENV['GA_SERVICE_ACCOUNT_EMAIL'], key)

service_account = Google::APIClient::JWTAsserter.new(
  ENV['GA_SERVICE_ACCOUNT_EMAIL'],'https://www.googleapis.com/auth/prediction', key)

截止日期 ArgumentError: wrong number of arguments (2 for 3..4) on jwt_asserter.rb:66:in 'initialize'

每次我尝试使用 #visitors 方法查询时,我都会收到 Insuficient Permission。我做错了什么?

编辑:

我变了

'https://www.googleapis.com/auth/prediction' -> https://www.googleapis.com/auth/analytics.readonly

并且消息发生了变化

User does not have any Google Analytics account

我只需要在

上授予 123@developer.gservice... 权限
Manage > User Management tab