このチュートリアルの次の記事はUsing OAuth 2.0 for Server to Server Applicationsです。サービスアカウントを使用してGmail APIに接続しようとしています。Gmail APIサーバーからサーバーアプリケーションへ(不正リクエストエラー)
私はこのようなルックスで終わるコード:
from oauth2client.service_account import ServiceAccountCredentials
from httplib2 import Http
from apiclient.discovery import build
import json
scopes = ['https://www.googleapis.com/auth/gmail.readonly']
credentials = ServiceAccountCredentials.from_json_keyfile_name('******.json', scopes)
http_auth = credentials.authorize(Http())
service = build('gmail', 'v1', http=http_auth)
request = service.users().messages().list(userId='me')
response = request.execute()
print json.dumps(response, sort_keys=True, indent=2)
私はこのコードを実行するときしかし、私は次のエラーを取得する:
googleapiclient.errors.HttpError:https://www.googleapis.com/gmail/v1/users/me/messages?alt=json returned "Bad Request">
誰かがどこにこのエラー私が理解するのに役立ちますにから来ていますか?