首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >google tasks api权限不足

google tasks api权限不足
EN

Stack Overflow用户
提问于 2018-08-03 20:21:17
回答 1查看 341关注 0票数 1

我正在按照下面的步骤访问Google Tasks,找到here,安装库,复制Python的代码,在我的电脑上执行快速入门,它就工作了。

在此之后,我更改了代码以编写任务,以下是代码:

代码语言:javascript
复制
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()

请注意,我将作用域更改为write privilege,但收到一个错误消息“权限不足”。我该如何解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-08 21:16:21

好了,我找到答案了。问题是,当我第一次运行程序时,它创建了一个只读访问的令牌文件。第二次运行程序时,即使我更改了源代码中的作用域,脚本仍然使用第一次运行时创建的旧令牌。解决方案是,在第二次运行之前删除令牌文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51672528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档