简体   繁体   中英

Calling an API which needs a Bearer Access Token

I am trying to call an API which I have been instructed:

This is expecting an Authorization header: Bearer Access Token.

I have the Bearer Access Token, and have tried via Postman, and via C# using WebRequest, to no avail.

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:

Header: "Authorization"
Value: "mytoken"

I have also tried

Header: "Bearer"
Value: "mytoken"

Also

Header: "Authorization"
Value: "Bearer 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?

What is the right way to give an API the bearer access token? Is the token meant to be encoded?

Try to add this line in your header on Postman:

Authorization: Bearer <token>

It should work...

Better would be to select "Authorisation" tab and add the Token like below:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM