Czy ktoś może podać mi jasne wyjaśnienie, jak uzyskać interfejs API Kalendarza Google v3 z klientem Python? W szczególności początkowy etap OAuth bardzo mnie myli. Wszystko, co muszę zrobić, to uzyskać dostęp do własnego kalendarza, przeczytać go i wprowadzić w nim zmiany. Google udostępnia ten kod do konfiguracji mojej aplikacji:Korzystanie z Google Calendar API v 3 z Pythonem
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')
Ale (a) nie ma dla mnie żadnego sensu; objaśnienia komentarza są okropne i (b) nie wiem, co umieścić w zmiennych. Zarejestrowałem swój program w Google i zarejestrowałem klucz do konta usługi. Ale wszystko, co mi dałem, to zaszyfrowany plik klucza do pobrania i identyfikator klienta. Nie mam pojęcia, co to jest "developerKey" lub czym jest "client_secret"? Czy to jest klucz? Jeśli tak, jak mogę to uzyskać, skoro jest on zawarty w zaszyfrowanym pliku? Wreszcie, biorąc pod uwagę względnie proste cele mojego wykorzystania API (tj. Nie jest to operacja wielodostępowa dla wielu użytkowników), czy istnieje prostszy sposób robienia tego? Dzięki.
Uważam, że dokumentacja Google Calendar API v3 jest niesamowicie zagadkowa. – Dimitris