如何处理缩放和API调用错误 [英] How to deal with zoom and api call errors

查看:160
本文介绍了如何处理缩放和API调用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.'}

此错误是设置缩放api时的错误吗? 我正在尝试使用zoom API获取会议列表. 我想打印通过print获得的内容.

Is this error an error on setting zoom api? I am trying to get the conference list in zoom api. I want to print the contents acquired by get with print.

推荐答案

您创建了JWT令牌,但未在API调用中使用它.您应该在Authorization标头中使用JWT令牌

You create your JWT token, but you don't use it in the API call. You should use your JWT token in the Authorization header

'authorization': "Bearer " + token,

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

or add it to your query as a path parameter:

&access_token=token

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

这篇关于如何处理缩放和API调用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆