oauth2 + 输出访问令牌打印

时间:2021-03-05 21:16:22

标签: python oauth-2.0

我只需要输出访问令牌:[xxxxx] oauth 你能帮我吗?

代码:

import requests  
    url = "xxxxy/v3/oauth2/token"
    
    payload = {
        "grant_type": "client_credentials",
        "client_id": "xxxxx",
        "client_secret": "xxxxx"
    }
    headers = {
        "Accept": "application/json",
        "Content-Type": "application/json"
    }
    
    response = requests.request("POST", url, json=payload, headers=headers)
    
    print(response.text)

输出: 在输出中,我们可以看到 access_token、令牌类型和此密钥的到期时间。 我只想输出来自“access_token”的代码。

{
"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxx"
"token_type":"bearer"
"expires_in":3600
}

0 个答案:

没有答案