401 reply when trying to use Twitch API

Hi Postman Community,

I am trying to fetch data from the twitch API using postman.

However after getting a OAutencication token using the post function I still get the following error message.

Can anyone help

image

Hey @alexander.agidius.jo

Great to have you as part of the community! :rocket:

Can you share the documentation you’re following please and how you’re using that token in the POST request?

Your question is light on details and it’s difficult to know exactly what you’re doing from that single image. :grin:

A basic example from their documentation shows that the requests require a client-id and an Authorization token.

curl --location --request
GET 'https://api.twitch.tv/helix/search/channels?query=a_seagull' \
--header 'client-id: wbmytr93xzw8zbg0p1izqyzzc5mbiz' \
--header 'Authorization: Bearer 2gbdx6oar67tqtcmt49t3wpcgycthx'

Are you using both?

Hi @danny-dainton

Thanks for your fast reply!

Sorry about the missing details, I’m quite new in the API environment and working a bit blind.

I am following this documentation to get the number of active streams

I have already created a developer app in the twitch environment to get client ID and Client secret, which i used to get the OAuth token.

However, when I use the get function i get an 401 error where I cant match the client ID and token.

How this makes more sense :slight_smile:

Everyone starts somewhere - It’s all good. Let’s see what we can do for you… :heart:

From those docs, it looks like those values need to be Headers rather than Query Parameters, in the GET request.

If you remove them from that section and add them to the Headers section, that should be it.

Just need to ensure that the keys are the correct case (Authorization and Client-Id) and the value says Bearer and not bearer at the start.

You could use the curl example request in the docs as a template and import that into Postman - Select Import > Raw text > Paste the command:

curl -X GET 'https://api.twitch.tv/helix/streams' \
-H 'Authorization: Bearer 2gbdx6oar67tqtcmt49t3wpcgycthx' \
-H 'Client-Id: wbmytr93xzw8zbg0p1izqyzzc5mbiz'

That would create the request and all you would need to do is swap the example values for your own tokens:

It worked right away with the import function.

Thank you so much for your help!

1 Like