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
Don't pass bearer tokens in page URLs: Bearer tokens SHOULD NOT be passed in page URLs (for example, as query string parameters). Instead, bearer tokens SHOULD be passed in HTTP message headers or message bodies for which confidentiality measures are taken.
Bearer tokens enable requests to authenticate using an access key, such as a JSON Web Token (JWT). The token is a text string, included in the request header. In the request Authorization tab, select Bearer Token from the Type dropdown list. In the Token field, enter your API key value.
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).
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.
On Postman go to:
If you want it in the URL too like you mentioned, just pass it in as parameter in the GET request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With