几年前,我创建了一个小Python程序,该程序能够使用oauth2client维护我的日历,而oauth2client现在已被弃用,取而代之的是谷歌.auth-但是我找不到任何有用的文档,我的程序停止工作,抱怨一个_modulekeyerror,除了升级,似乎没有人能解决这个问题。在
我不知道如何将oauth2client替换为谷歌.auth公司名称:
import datetime
import httplib2
import os
from apiclient import discovery
import oauth2client
from oauth2client import client
from oauth2client import tools
。。。在
^{pr2}$
根据oauth2client deprecation notes,用于管理Google用户凭证的替换项是google-auth-oauthlib。下面是在我的电脑上工作的代码片段(python3.6)。在
由于文档强调新库没有保存凭证,所以我使用pickle保存凭证。也许,根据您的应用程序需求,您希望有一个更健壮的解决方案(比如数据库)。在
我还没有对此进行过可靠的测试,但它可以用我的个人帐户测试代码片段。我确信对于企业应用程序,可以和/或应该对其进行更改,例如传递auth'd
Http()
实例,检测范围更改,等等。在您可以查看my GitHub repo上的完整代码:
要求:
我使用^{} 类,通常遵循Google's Python auth guide上的说明。在
代码(Python3.6)
那么用法是:
^{pr2}$相关问题 更多 >
编程相关推荐