Zoom api 问题 - 无效的访问令牌 - JWT
Posted
技术标签:
【中文标题】Zoom api 问题 - 无效的访问令牌 - JWT【英文标题】:Zoom api problem - invalid acces token - JWT 【发布时间】:2021-07-27 21:19:34 【问题描述】:import requests
import json
import jwt
import datetime
APİ_KEY = "100 percent correct api key"
APİ_SECRET = "100 percent correct api secret"
payload =
'iss':APİ_KEY,
'exp':datetime.datetime.now() + datetime.timedelta(hours=2)
token = jwt.encode(payload, APİ_SECRET)
print(token)
endpoint = "https://api.zoom.us/v2/users/my_e-mail_is_written_here/meetings"
myData =
"headers":
"authorization":"Bearer "+token,
"content-type":"application/json"
,
"body":
"topic":"denemex",
"type":2,
"start_time":"2021-05-05T13:20",
"duration":"40",
"password":"1234"
zoom_r = requests.post(endpoint, data=json.dumps(myData))
print(zoom_r.status_code)
print(zoom_r.text)
我想像这样用python做一个简单的实验,但是我得到一个“无效的访问令牌”错误,可能是什么原因?
【问题讨论】:
【参考方案1】:我对自己的问题想了很多,通过如下修改代码解决了这个问题:
import requests
import json
import jwt
import datetime
APİ_KEY = "my api key"
APİ_SECRET = "my api secret"
payload =
'iss':APİ_KEY,
'exp':datetime.datetime.now() + datetime.timedelta(hours=2)
token = jwt.encode(payload, APİ_SECRET)
endpoint = "https://api.zoom.us/v2/users/my_e-mail_is_written_here/meetings"
myData =
"topic":"denemex",
"type":2,
"start_time":"2021-05-05T13:20",
"duration":"40",
"password":"1234"
headers = "Content-Type":"application/json", "Authorization":"Bearer "+ token
zoom_r = requests.post(endpoint, headers=headers, data=json.dumps(myData))
print(zoom_r.status_code)
print(zoom_r.text)
【讨论】:
以上是关于Zoom api 问题 - 无效的访问令牌 - JWT的主要内容,如果未能解决你的问题,请参考以下文章
Microsoft Graph API 身份验证错误:“访问令牌验证失败。无效的受众”
使用访问令牌时,salesforce rest api 无效会话 id 错误
API 无效的随机 Facebook iOS SDK 身份验证令牌