简体   繁体   English

调用需要承载访问令牌的 API

[英]Calling an API which needs a Bearer Access Token

I am trying to call an API which I have been instructed:我正在尝试调用我被指示的 API:

This is expecting an Authorization header: Bearer Access Token.这需要一个 Authorization 标头:Bearer Access Token。

I have the Bearer Access Token, and have tried via Postman, and via C# using WebRequest, to no avail.我有不记名访问令牌,并通过 Postman 和 C# 使用 WebRequest 进行了尝试,但无济于事。

Within Postman I have the method set as GET, Authorization set as No Auth, on the Headers tab I have tried adding one header like so:在 Postman 中,我将方法设置为 GET,授权设置为 No Auth,在 Headers 选项卡上,我尝试添加一个标题,如下所示:

Header: "Authorization"标题:“授权”
Value: "mytoken"值:“我的令牌”

I have also tried我也试过

Header: "Bearer"标题:“承载”
Value: "mytoken"值:“我的令牌”

Also

Header: "Authorization"标题:“授权”
Value: "Bearer mytoken"值:“承载mytoken”

I think maybe it does not work in Postman because of some other headers sent from within PM, but surely from a test C# console application this should work?我想也许它在 Postman 中不起作用,因为从 PM 内部发送了一些其他标头,但肯定从测试 C# 控制台应用程序这应该工作?

What is the right way to give an API the bearer access token?为 API 提供不记名访问令牌的正确方法是什么? Is the token meant to be encoded?令牌是要编码的吗?

Try to add this line in your header on Postman:尝试在 Postman 的标题中添加此行:

Authorization: Bearer <token>

It should work...应该工作...

Better would be to select "Authorisation" tab and add the Token like below:更好的是选择“授权”选项卡并添加如下令牌:

图像显示了被添加到 PostMan 的授权部分的令牌

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

相关问题 使用 Bearer 令牌调用 Rest API - Calling a Rest API with Bearer token 重复使用Google Api Bearer令牌来访问用户的云端硬盘 - Reusing Google Api Bearer Token to access user's Drive Web API中的Decrypt Bearer Token - Decrypt Bearer Token in Web API DocusignApi JWT 访问令牌,用于调用管理员 api - DocusignApi JWT access token for calling admin api 如何实现允许承载令牌身份验证或 api 密钥身份验证的 ASP.Net Core API Controller - How to implement an ASP.Net Core API Controller which allows Bearer Token authentication OR api key authentication 使用AutoRest C#客户端访问带有承载令牌的Web API-TokenCredentials不起作用 - Using an AutoRest C# client to access a Web API with a bearer token - TokenCredentials does not work 在Ocelot API网关中添加授权Header(授权:Bearer {access_token})到特定路由 - Adding Authorization Header (Authorization: Bearer {access_token}) to specific route in Ocelot API Gateway OAuth承载访问令牌滑动到期 - OAuth Bearer Access Token sliding expiration JWT 不记名令牌:“观众 &#39;api://...&#39; 无效” - JWT Bearer Token: "The audience 'api://...' is invalid" 为多个API调用重用承载令牌 - Reusing a bearer token for multiple API calls
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM