googleapi:将auth_代码转换为access|token | Python

2024-10-03 21:34:48 发布

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

我正在尝试将客户端提供的auth_代码转换为后端的令牌。(前面和后面是两个不同的发球局)。在

scope='https://www.googleapis.com/auth/calendar' code='code=4/nQCEBlo_YbWfOw1NXCWJ3UCyRzPT*****NJbda0eaXdmv032qX2PZhV4Cd2YzO3sPQ36*************' # Exchange auth code for access token, refresh token, and ID token c = client.credentials_from_code('***ClientID*****-*****************.apps.googleusercontent.com' ,'SECRET*********',scope,code) print (c.id_token)

另一个尝试是:

    CLIENT_SECRET_FILE = 'client_secret.json'
credentials = client.credentials_from_clientsecrets_and_code(
    CLIENT_SECRET_FILE,
    ['https://www.googleapis.com/auth/calendar'],
    'code=4/nQCEBlo_YbWfOw1NXC****************4Cd2Y*********mGgA')

我收到这个错误:

^{pr2}$

有什么想法吗? 谢谢!


Tags: andfromhttpscomclienttokenauthsecret