내가 다음 예제와 같이 파이썬 클라이언트 라이브러리를 사용하여 서비스 계정 (클라이언트 이메일 및 P12 인증서)를 통해 구글 doubeclick API를 연결하기 위해 노력하고있어 계정 나에게 빈 access_token을 반환합니다.구글 API 서비스
In [9]: type(credentials.access_token)
Out[9]: <type 'NoneType'>
이 내용의 중요성은 무엇입니까? 내가 틀릴 가능성이있는 것이 있습니까? 또한 예제에서와 같이 작업 API에 액세스하려고 시도했지만 (아마도 doubleclick API가 지원되는 범위가 아니라고 생각할 때) 동일한 결과를 얻었습니다.
UPDATE (예제 코드) :
from oauth2client.client import SignedJwtAssertionCredentials
import httplib2
from adspygoogle.dfp import DfpClient
f = file('/path/to/.ssh/google-api.p12', 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials('<email>', key, scope='https://www.google.com/apis/ads/publisher')
credentials.refresh(http)
http = httplib2.Http()
http = credentials.authorize(http)
client = DfpClient.DfpClient(headers={'networkCode': '<code>', 'applicationName': 'test', 'userAgent': 'test', 'oauth2credentials': credentials})
inventory_service = client.GetInventoryService()
inventory_service.getAdUnitsByStatement({'query':''})
는 ERROR :
DfpAuthenticationError: [AuthenticationError.NO_NETWORKS_TO_ACCESS @ ]
새로 고침 토큰이 있습니까? –
아니요 새로 고침 토큰이 없습니다 (공란으로 표시됨) –
추가 명령 행 플래그로'--dump_request_response'를 전달해보십시오. 이렇게하면 서버와의 대화를 stdout으로 덤프해야합니다. 그러면 문제가 무엇인지 알 수 있습니다. 위와 같이 [i] 파이썬 세션에서 실행중인 경우 다음을 원합니다.'import gflags; gflags.FLAGS.dump_request_response = True' –