Google Admin SDK Reports V1 API를 사용하여 Google Apps 관리자 패널에서 모든 관리 활동을 수집하고 있습니다. 승인을 시도 할 때 Google Admin SDK 오류 401
내 구글 API를 파이썬 클라이언트
는 최근 이전에 나는 다음과 같은 사용 된 버전"google-api-python-client (1.5.1)"
으로 업데이트되었습니다
from oauth2client.client import SignedJwtAssertionCredentials
serviceAccountEmail = "[email protected]"
key = "google-apps-file.p12"
scopes = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']
credentials = SignedJwtAssertionCredentials(
serviceAccountEmail, key, scope=scopes, sub=userEmail)
그런 다음 구글 SignedJwtAssertionCredentials에 대한 지원을 떨어졌다. 그래서 나는 이것으로 바꾸었다.
from oauth2client.service_account import ServiceAccountCredentials
serviceAccountEmail = "[email protected]"
key = "google-apps-file.p12"
scopes = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']
credentials = ServiceAccountCredentials.from_p12_keyfile(
serviceAccountEmail, key, scopes=scopes)`
좋아, 이렇게하면 비교적 간단한 작은 코드를 변경해야하지만 코드를 실행할 때 다음과 같은 오류가 발생합니다.
File "/usr/local/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/googleapiclient/http.py", line 832, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 401 when requesting https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/admin?alt=json returned "Access denied. You are not authorized to read activity records.">
그래서 아무 권한은 생각 납니까 한 가지가 원래의 코드가
sub=userEmail
요구된다, 변경되지 않은 (가장 할 계정이다, 그 계정이 Google Apps 도메인을 통해 특정 관리자 권한이 있어야합니다.)
401
을 얻을 수 있지만 새 설명서에는 sub=userEmail
매개 변수에 대한 언급이 없습니다.