Python OAuth 2.0嵌入式客户端\ u secret.json

2024-10-01 00:18:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个程序,用python quickstart在google calendare上标记约会,一切正常,但是程序从纯文本文件中读取client\u secret.jsoncredential.json信息,而这些信息应该受到保护

我想对文件进行加密,但是如何通过传递文件内容(字符串)而不是文件本身来执行client.flow\u from\u clientsecrets过程

我想避免编辑googleapi python客户端


Tags: 文件字符串标记程序client信息json内容
1条回答
网友
1楼 · 发布于 2024-10-01 00:18:02

您可以使用OAuth2WebServerFlow

from oauth2client.client import OAuth2WebServerFlow

flow_params = {
    'access_type': 'offline',
    'prompt': 'consent'
}

flow_scopes = [
    "https://www.googleapis.com/auth/calendar.edit",
    "https://www.googleapis.com/auth/calendar",
]

flow = OAuth2WebServerFlow(
    client_id=client_id,
    client_secret=client_secret,
    scope=flow_scopes,
    redirect_uri='http://www.redirect_uri.com',
    **flow_params
)

相关问题 更多 >