Mike
Mike

Reputation: 181

API, passing bearer token to GET HTTP URL

I have a OAuth2 (bearer token), but how do I pass it to the endpoint? More precisely, how do I include the bearer token in the URL.

Example URL:

https://api.twitter.com/1.1/search/tweets.json?q=%23superbowl&result_type=recent

Example Bearer Token:

AAAAA5n0w5n0w5n0wMyL0ngBe4r4rT0k4n

How do I use my bearer token to authorize my requests?

Example Incorrect Usage:

https://api.twitter.com/1.1/search/tweets.json?q=%23superbowl&result_type=recent&bearer=AAAAA5n0w5n0w5n0wMyL0ngBe4r4rT0k4n

Upvotes: 18

Views: 119344

Answers (5)

Alon Kolyakov
Alon Kolyakov

Reputation: 23

Follow these steps:

  1. https://base.url and set the request type.
  2. Now under the url there is an Authorization tab --> click it.
  3. When you in the Authorization tab select the Authorization type and fill the required token fields.

You are using the OAuth 2.0 but there several more API Key / Bearer Token / ..

  1. Before sending the request Make sure to send a body if the request is waiting for a parameters.
  • Body tab under the url field --> click it.
  • Selected the required datatype none / form-data / raw / ..
  • If the raw datatype was selected make sure to select the schema-type

Text / javascript / JSON / HTML / XML

Here is a quick explaination video:

https://www.screencast.com/t/E3igDLQE

Upvotes: 0

simhumileco
simhumileco

Reputation: 34643

You can do it in two equivalent ways:

  • by using the URL access_token parameter:

    https://base.url?access_token=f4f4994a875f461ca4d7708b9e027df4
  • or by adding the Authorization header:

    Authorization: Bearer f4f4994a875f461ca4d7708b9e027df4

Note: Whether two or only one of these methods works sometimes depends on the specific implementation of the web application (including the services and libraries used to create it).

Upvotes: 33

santhosh kumar
santhosh kumar

Reputation: 31

https://YourApiUrl?access_token=0db69822-0d02-4c17-8c39-d3b818bee184

Append the valid bearer token as value to the key "access_token". This worked for me.

Upvotes: 3

user6250770
user6250770

Reputation: 690

example of use the authorization header in url

FYI,

https://Endpointurl?Authorization=Bearer 00D2w000000kc19!AQ0AQAXCu2pbsBn4YvKuvUbNieCGmG2CVL4lqVaJruAXKZYWuAQiuxtuMiOgvGw2KQ.E4CJtkOdUw0_Q7yUzQh_3XAgwWQfd

Hope you understood how to pass the token

Upvotes: -3

Ud0
Ud0

Reputation: 69

On Postman go to:

  1. Authentication tab
  2. Select type: Bearer Token
  3. Paste in your Token

If you want it in the URL too like you mentioned, just pass it in as parameter in the GET request.

Postman bearer token screenshot

Upvotes: 2

Related Questions