【问题标题】:How to deal with zoom and api call errors如何处理缩放和 api 调用错误
【发布时间】:2019-10-04 09:25:58
【问题描述】:

当我创建 jwt 并调用 Zoom api 时,我收到错误 {'code': 124, 'message': 'Invalid access token.'}。这是什么意思?

ApiKey = 'xxx'
ApiSercret = 'xxx'
mail = request.POST['mail']
print(mail)
today = datetime.today()
header = {
'alg':'HS256'
}

payload = { 
'iss': ApiKey,
'exp': today + timedelta(hours=1),
}

#https://docs.authlib.org/en/latest/specs/rfc7519.html#authlib.jose.rfc7519.JWT.check_sensitive_data
token = jwt.encode(header,payload,ApiSercret,check='true')
print(token)
import http.client

        conn = http.client.HTTPSConnection("api.zoom.us")

        headers = {
            'authorization': "Bearer 39ug3j309t8unvmlmslmlkfw853u8",
            'content-type': "application/json"
        }   

        conn.request("GET", "/v2/users?status=active&page_size=30&page_number=1", headers=headers)

        res = conn.getresponse()
        data = res.read()

        print(data.decode("utf-8"))
        
params = {
mail:token
}

return render(request,'api/index.html',params)

错误内容:

{'code': 124, 'message': 'Invalid access token.'}

这个错误是设置 Zoom api 的错误吗? 我正在尝试在 Zoom api 中获取会议列表。 我想打印get with print获取的内容。

【问题讨论】:

    标签: python django jwt zoom-sdk


    【解决方案1】:

    您创建了自己的 JWT 令牌,但并未在 API 调用中使用它。您应该在 Authorization 标头中使用您的 JWT 令牌

    'authorization': "Bearer " + token,
    

    或将其作为路径参数添加到您的查询中:

    &access_token=token
    

    https://marketplace.zoom.us/docs/guides/authorization/jwt/authentication

    【讨论】:

    • 不要将其添加为查询令牌。推荐在authorization 标头或cookies
    猜你喜欢
    • 2023-01-16
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    • 1970-01-01
    • 2011-04-22
    • 1970-01-01
    • 2021-10-24
    相关资源
    最近更新 更多