I'm following the steps to access the Google Tasks API found here, installed the libraries, copied the code for Python, executed the quickstart in my computer and it worked.
After that I changed the code to write a task, Here is the code:
from __future__ import print_function
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file as oauth_file, client, tools
# If modifying these scopes, delete the file token.json.
SCOPES = 'https://www.googleapis.com/auth/tasks'
def main():
store = oauth_file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('tasks', 'v1', http=creds.authorize(Http()))
tasklist_id = "theidofmygoogletasklist"
task = {
'title': 'Study Python',
'notes': '',
'due': ''
}
# Call the Tasks API
results = service.tasks().insert(tasklist=tasklist_id, body=task).execute()
print(result['id'])
if __name__ == '__main__':
main()
Note that I changed the SCOPE to write privilege But I'm getting an error saying "Insufficient Permission". How can I solve this problem?