0

I enabled Task Queue API in my_project of Google Cloud Platform.

And I generated OAuth client-id for web-application and set redirect URL to https://my_project.appspot.com/oauth2callback.
And I add (decorator.callback_path, decorator.callback_handler()) to webapp2.WSGIApplication.

from oauth2client.contrib.appengine import OAuth2DecoratorFromClientSecrets
from googleapiclient.discovery import build

decorator = OAuth2DecoratorFromClientSecrets(
'my.json', scope='https://www.googleapis.com/auth/tasks.readonly')

@decorator.oauth_aware
def get_google_client_credential_tasks(self):
    http = decorator.http()

    service_tasks = build('tasks', 'v1', http=http)

    temp_str = ''
    tasklists = service_tasks.tasklists().list().execute(http=http)
    for tasklist in tasklists[0]['items']:
        temp_str += tasklist['title']

    self.response.write(temp_str)

When I execute the above code, I got the following error message.

https://www.googleapis.com/tasks/v1/users/@me/lists?alt=json returned "Insufficient Permission">

How do I fix the error?

1 Answer 1

1
@decorator.oauth_aware
def get_google_client_credential_tasks(self):
    if decorator_google_client.has_credentials():
        http = decorator.http()

        service_tasks = build('tasks', 'v1', http=http)

        temp_str = ''
        tasklists = service_tasks.tasklists().list().execute(http=http)
        for tasklist in tasklists[0]['items']:
            temp_str += tasklist['title']

        self.response.write(temp_str)
    else:
        url = decorator_google_client.authorize_url()
        self.redirect(url)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.