일부 실험 정보를 푸시하기 위해 Google 애널리틱스 API에 액세스하는 Ruby 앱을 작성 중입니다.Google Analytics API : "사용자에게이 계정에 대한 충분한 권한이 없습니다."
앱을 연결하고 다음과 같은 기능을 통해 구글 서비스 계정을 사용하여 인증 : 인증하고 문제없이 두 API를 발견
def connect
...
@@client = Google::APIClient.new(:application_name => 'My Service App',
:application_version => '1.0.0')
key_file = Rails.root.join('config', 'privatekey.p12').to_s
key_secret = 'somesecret'
key = Google::APIClient::PKCS12.load_key(key_file, key_secret)
asserter = Google::APIClient::JWTAsserter.new(
SECRETS[:google_service_account_email],
['https://www.googleapis.com/auth/yt-analytics.readonly',
'https://www.googleapis.com/auth/analytics.readonly'
],
key
)
@@client.authorization = asserter.authorize()
...
end
....
YouTube 분석 API에 대해 클라이언트를 사용하면 문제없이 작동합니다. 똑같은 계정을 사용하면 403 오류 응답에 ...
response = @@client.execute({
# 'analytics is the API object retrieved via discover_api()
:api_method => analytics.management.experiments.list,
:parameters => {
'accountId' => 'AAAAAAAA',
'profileId' => 'PPPPPPPP',
'webPropertyId' => 'UA-WWWWWWWW-#'
}
})
결과를 웹 로그 분석 API를 통해 액세스 할 수 : 권한 부여에 관해서
{"domain":"global","reason":"insufficientPermissions","message":"User does not have sufficient permissions for this account."}
, 내가 두 번 확인 계정 서비스를 @ myapp.com :
- 는 Google 웹 로그 분석 웹 인터페이스에 대한 모든 권한을 가지고 있습니다.[email protected] 계정을 사용하여 로그인했으며 내가 시도한 동일한 실험을 볼 수있었습니다.
- Analytics API를 사용하도록 설정했습니다. API 콘솔에서 서비스 섹션에서 Analytics API 항목이 ON으로 전환되었음을 확인했습니다. (YouTube 분석과 마찬가지로)
- 적절한 AccountID, ProfileID 및 WebPropertyID 값을 사용하고 있습니다. Google 애널리틱스 웹 인터페이스에서 직접 복사했습니다.
서비스 계정이 적어도 하나의 API (YouTube 웹 로그 분석)에 액세스 할 수 있음을 감안할 때, 및 관련 계정 ([email protected]) 웹 로그 분석 웹 인터페이스에 액세스 할 수 있습니다 서비스 계정에 문제가있을 것 같습니다 특히 애널리틱스 API에 액세스합니다.
아이디어가 있으십니까?
비슷한 주제 :
- “Not sufficient permissions” google analytics API service account (참고 :이 오류는 나보다 약간 다릅니다)
- Analytics blog post, check comments section for 'permissions'
실제 GA 프로필에서 서비스 계정에 대한 권한을 부여 했습니까? 관리>보기> 사용자 관리> "권한 추가 :" – Goose
[email protected] 계정에 모든 권한이 있습니다. 그러나 귀하의 의견에 따라 실제 서비스 계정 이메일 (예 : [email protected])을 추가하라는 메시지가 표시되어 문제를 해결하는 것으로 보입니다. 이것을 답 형식으로 쓰고 싶다면 기꺼이 크레딧을 드리겠습니다. –
[Analytics Google API 오류 403 : "사용자에게 Google 웹 로그 분석 계정이 없습니다"] (http://stackoverflow.com/questions/12837748/analytics-google-api-error-403-user-does-not) -have-any-google-analytics-account) – andygeers