1
當我使用gdata-python-client庫https://github.com/google/gdata-python-client/blob/master/samples/apps/email_audit_email_monitoring.py時,我在開始時遇到錯誤。如何使用電子郵件審計API與gdata python客戶端庫?
import re
import sys
import gdata
from gdata.apps.audit.service import AuditService
consumer_key = ""
consumer_secret = ""
domain = "connect-with.in"
service = AuditService(domain=domain, source='emailAuditSample')
service.SetOAuthInputParameters(gdata.auth.OAuthSignatureMethod.HMAC_SHA1, consumer_key, consumer_secret)
request_token = service.FetchOAuthRequestToken()
service.SetOAuthToken(request_token)
auth_url = service.GenerateOAuthAuthorizationURL()
print auth_url
raw_input('Manually go to the above URL and authenticate.'
'Press Return after authorization.')
service.UpgradeToOAuthAccessToken()
它總是說
in line 12 gdata.service.FetchingOAuthRequestTokenFailed: {'status': 400, 'body': 'Consumer is not registered: 138497053107-69esj3btdoq14i27qtqkuhr26vfiq65s.apps.googleusercontent.com\n\n', 'reason': 'Non 200 response on fetch request token'}
我曾經在谷歌開發者控制檯應用的客戶端ID和客戶端密鑰,但它不工作。那麼哪個關鍵和祕密會起作用?
你在哪裏定義Auth url參數和範圍? – KayAnn