简体   繁体   English

如何在 python api 中传递不记名令牌

[英]how to pass bearer token in python api

How to pass bearer token in API call using python request module?如何使用 python 请求模块在 API 调用中传递不记名令牌? Below I have tried:下面我尝试过:

                            import requests
                            import json
                            api_url = " "# url
                            todo = "" #Data to send
                            headers =  {"Content-Type":"application/json"} # how to pass bearer token
                            response = requests.post(api_url, data=json.dumps(todo), headers=headers)
                            print(response.json())
 

Define token before and change headers to:在之前定义令牌并将标题更改为:
headers = {"Content-Type":"application/json", "Authorization": f"Bearer {token}"}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 python lambda function 通过 Z8A5DA52ED1206747D8AAZGatewayA70 传递和读取授权不记名令牌? - How to pass and read authorization bearer-token using python lambda function through api gateway? 如何在 url 中传递不记名令牌 - How to pass bearer token in url Flask Rest API - 如何在 python 请求中使用 Bearer API 令牌 - Flask Rest API - How to use Bearer API token in python requests Python 使用承载令牌获取 API 响应 - Python get API responses using Bearer Token 如何将不记名令牌传递给 Postman 中的原始 websocket - How to pass bearer token to raw websocket in Postman 如何将接收到的(承载)访问令牌传递给生成的 REST 客户端以调用安全的 API-Gateway 端点 - How to pass received (bearer) access token to generated REST Client in order to invoke secured API-Gateway Endpoint 如何使用 python 以编程方式获取 GCP Bearer 令牌 - How to get a GCP Bearer token programmatically with python 如何通过来自 python 的请求获取不记名令牌 - How get bearer token with requests from python 使用需要不记名令牌的 API 在 Python 中进行 API 调用 - Making an API call in Python with an API that requires a bearer token 如何在Swagger Codegen 3.x生成的Python API客户端中设置Bearer token? - How to set the Bearer token in the Python API client generated by Swagger Codegen 3.x?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM