如何在我的本地Python代码中使用consent screen获得Google OAuth 2.0授权?
在我的Google Colab笔记本中,我也可轻松完成此操作,例如,访问我的Google表格
from oauth2client.client import GoogleCredentials
from google.colab import auth
import gspread
auth.authenticate_user()
gc = gspread.authorize(GoogleCredentials.get_application_default())
这会在我的浏览器中打开Google Colab同意屏幕,我会在其中登录我的工作表所在的帐户并获取我为响应提示而粘贴的令牌。
如何在本地Jupyter笔记本或代码中打开我的同意屏幕?是否有上述流程将启动同意屏幕,允许我在那里进行身份验证,收集(临时)令牌,并粘贴它以响应提示的提示?
在Colab之外不提供google.colab
图书馆。
gspread
文档描述了如何通常对库进行身份验证:https://github.com/burnash/gspread#basic-usage
重现相关代码段:
import gspread
gc = gspread.authorize(credentials)
大部分工作都是通过链接中描述的云项目创建过程完成的。