Kann mir bitte jemand eine klare Erklärung geben, wie Sie die Google Kalender API v3 mit dem Python-Client arbeiten lassen? Insbesondere die anfängliche OAuth-Phase verwirrt mich sehr. Alles, was ich tun muss, ist, auf meinen eigenen Kalender zuzugreifen, ihn zu lesen und Änderungen daran vorzunehmen. Google stellt diesen Code zur Konfiguration meiner App zur Verfügung:Verwenden der Google Kalender API v3 mit Python
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')
Aber (a) es macht absolut keinen Sinn für mich; Die Kommentare sind schrecklich und (b) ich weiß nicht, was ich in die Variablen schreiben soll. Ich habe mein Programm bei Google registriert und mich für einen Dienstkontoschlüssel angemeldet. Aber alles, was mir zur Verfügung stand, war eine verschlüsselte Schlüsseldatei zum Herunterladen und eine Client-ID. Ich habe keine Ahnung, was ein "developerKey" ist oder was ein "client_secret" ist? Ist das der Schlüssel? Wenn ja, wie bekomme ich es, da es tatsächlich in einer verschlüsselten Datei enthalten ist? Angesichts der relativ einfachen Ziele meiner API-Nutzung (d. H. Es handelt sich nicht um eine Multi-User-, Multi-Access-Operation) gibt es einen einfacheren Weg, dies zu tun? Vielen Dank.
Ich finde die Google Kalender API v3 Dokumentation unglaublich kryptisch. – Dimitris