Google Calendar API v3 を Python クライアントで動作させる方法について、誰かが明確に説明してくれませんか? 具体的には、OAuth の初期段階で非常に混乱します。自分のカレンダーにアクセスし、それを読み、変更するだけです。Google は、アプリを構成するために次のコードを提供しています。
import gflags
import httplib2
from apiclient.discovery import build
from oauth2client.file import Storage
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.tools import run
FLAGS = gflags.FLAGS
# Set up a Flow object to be used if we need to authenticate. This
# sample uses OAuth 2.0, and we set up the OAuth2WebServerFlow with
# the information it needs to authenticate. Note that it is called
# the Web Server Flow, but it can also handle the flow for native
# applications
# The client_id and client_secret are copied from the API Access tab on
# the Google APIs Console
FLOW = OAuth2WebServerFlow(
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
scope='https://www.googleapis.com/auth/calendar',
user_agent='YOUR_APPLICATION_NAME/YOUR_APPLICATION_VERSION')
# To disable the local server feature, uncomment the following line:
# FLAGS.auth_local_webserver = False
# If the Credentials don't exist or are invalid, run through the native client
# flow. The Storage object will ensure that if successful the good
# Credentials will get written back to a file.
storage = Storage('calendar.dat')
credentials = storage.get()
if credentials is None or credentials.invalid == True:
credentials = run(FLOW, storage)
# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with our good Credentials.
http = httplib2.Http()
http = credentials.authorize(http)
# Build a service object for interacting with the API. Visit
# the Google APIs Console
# to get a developerKey for your own application.
service = build(serviceName='calendar', version='v3', http=http,
developerKey='YOUR_DEVELOPER_KEY')
しかし、(a)それは私にはまったく意味がありません。コメントの説明がひどい。(b) 変数に何を入れたらいいのかわからない。プログラムを Google に登録し、サービス アカウント キーにサインアップしました。しかし、私に与えられたのは、ダウンロードするための暗号化されたキー ファイルとクライアント ID だけでした。「developerKey」とは何か、または「client_secret」とは何かわかりませんか? それが鍵ですか?もしそうなら、実際には暗号化されたファイルに含まれているので、どうすれば取得できますか? 最後に、私の API 使用の比較的単純な目標 (つまり、マルチユーザー、マルチアクセス操作ではない) を考えると、これを行うためのより簡単な方法はありますか? ありがとう。