Error - #<Google::Apis::ClientError: insufficientPermissions: User does not have any Google Analytics account.>

634 views Asked by At

I want to get the Behaviour Report from my Company's GA Account.

I used the following code.

`

require 'google/apis/analytics_v3'
require 'googleauth'

scope = 'https://www.googleapis.com/auth/analytics.readonly'
analytics = Google::Apis::AnalyticsV3::AnalyticsService.new
analytics.authorization = Google::Auth::ServiceAccountCredentials.make_creds({
"json_key_io": Rails.root.join('/GoogleAnalyticsXXXXX.json'),
"scope": scope
})
analytics.authorization.fetch_access_token!
end
end

analytics.get_ga_data('ga:XXXXXX', Time.now.to_date.to_s, Time.now.to_date.to_s, "ga:sessions,ga:pageviews")

But It throws error.

Error - #<Google::Apis::ClientError: insufficientPermissions: User does not have any Google Analytics account.>

Google::Apis::ClientError: insufficientPermissions: User does not have any Google Analytics account.
from /Users/user_name/.rvm/gems/ruby-2.2.2/gems/google-api-client-0.13.3/lib/google/apis/core/http_command.rb:218:in check_status' from /Users/user_name/.rvm/gems/ruby-2.2.2/gems/google-api-client-0.13.3/lib/google/apis/core/api_command.rb:116:incheck_status'
from /Users/user_name/.rvm/gems/ruby-2.2.2/gems/google-api-client-0.13.3/lib/google/apis/core/http_command.rb:183:in `process_response'

Please let me know what Am I missing

0

There are 0 answers