Note that there are some explanatory texts on larger screens.

plurals
  1. POUse 2 legged in Google API v3 for python
    primarykey
    data
    text
    <p>I have the code as describe here. I need to create a lot of events in my calendar.</p> <p>I cannot find a way to make it work. Using 2 legged seems to be deprecated </p> <pre class="lang-python prettyprint-override"><code>import sys import httplib2 from rfc3339 import rfc3339 from apiclient.discovery import build from oauth2client.file import Storage from oauth2client.client import AccessTokenRefreshError from oauth2client.client import flow_from_clientsecrets from oauth2client.tools import run import pytz import datetime import time start_zone = pytz.timezone('Europe/London') end_zone = pytz.timezone('Europe/Oslo') start_time = datetime.datetime(2013,8,13,15,0, tzinfo=start_zone) end_time = datetime.datetime(2013,8,16,19,0, tzinfo=end_zone) flow = flow_from_clientsecrets('client_secrets.json', scope='https://www.googleapis.com/auth/calendar', redirect_uri='http://localhost') storage = Storage('credentials.dat') credentials = storage.get() if credentials is None or credentials.invalid: credentials = run(flow, storage) http = httplib2.Http() http = credentials.authorize(http) service = build('calendar', 'v3', http=http) try: event = { 'start': { 'dateTime': start_time }, 'end': { 'dateTime': end_time }, "summary": "New event", "location": "Paris, FRANCE" } service.events().insert(calendarId='primary', body=event).execute() print "END" except AccessTokenRefreshError: print ('Credentials have been revoked') </code></pre> <p>I have updated my code this way (since i don't have redirection)</p> <pre class="lang-python prettyprint-override"><code>#!/usr/bin/python import sys import httplib2 from rfc3339 import rfc3339 from apiclient.discovery import build from oauth2client.file import Storage from oauth2client.client import AccessTokenRefreshError from oauth2client.client import flow_from_clientsecrets from oauth2client.tools import run import pytz import datetime import time start_zone = pytz.timezone('Europe/London') end_zone = pytz.timezone('Europe/Oslo') start_time = datetime.datetime(2013,8,13,15,0, tzinfo=start_zone) end_time = datetime.datetime(2013,8,16,19,0, tzinfo=end_zone) flow = flow_from_clientsecrets('client_secrets.json', scope='https://www.googleapis.com/auth/calendar', redirect_uri='urn:ietf:wg:oauth:2.0:oob') auth_uri = flow.step1_get_authorize_url() print('Visit this site!') print(auth_uri) code = raw_input('Insert the given code!') credentials = flow.step2_exchange(code) print(credentials) with open('credentials.dat', 'wr') as f: f.write(credentials.to_json()) storage = Storage('credentials.dat') credentials = storage.get() if credentials is None or credentials.invalid: credentials = run(flow, storage) http = httplib2.Http() http = credentials.authorize(http) service = build('calendar', 'v3', http=http) try: event = { 'start': { 'dateTime': start_time }, 'end': { 'dateTime': end_time }, "summary": "New event", "location": "Paris, FRANCE" } service.events().insert(calendarId='primary', body=event).execute() print "END" except AccessTokenRefreshError: print ('Credentials have been revoked') </code></pre> <p>So when I run my script, it opens a window ad asking me to login. So I put my gmail username/password and I have the following error after that:</p> <pre><code>Error: redirect_uri_mismatch The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob did not match a registered redirect URI </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload