title: Issues accessing Twitch API through Python
body: <p>I am trying to access the Twitch API to make a simple request for channel details. I am consistently being met with a 401 Unauthorised error despite feeding in the OAUTH code I am generating successfully. I am using the formatting found in the docs:</p>
  <pre><code>GET 'https://api.twitch.tv/helix/search/channels?query=a_seagull' \
  --header 'client-id: wbmytr93xzw8zbg0p1izqyzzc5mbiz' \
  --header 'Authorization: Bearer 2gbdx6oar67tqtcmt49t3wpcgycthx'
  </code></pre>
  <p>This is what is written on the website. I have translated this into Python:</p>
  <pre class="lang-py prettyprint-override"><code>import os
  import requests
  
  URL = &quot;https://id.twitch.tv/oauth2/token&quot;
  CLIENT_ID = os.environ['CLIENT_ID']
  CLIENT_SECRET = os.environ['CLIENT_SECRET']
  GRANT_TYPE = &quot;client_credentials&quot;
  PARAMS = {
    &quot;client_id&quot;: CLIENT_ID,
    &quot;client_secret&quot;: CLIENT_SECRET,
    &quot;grant_type&quot;: GRANT_TYPE
  }
  
  r1 = requests.post(url = URL, params = PARAMS)
  
  token = r1.json()[&quot;access_token&quot;]
  
  
  URL2 = &quot;https://api.twitch.tv/helix/search/channels?query=reisu1337&quot;
  PARAMS2 = {
    &quot;client_id&quot;: CLIENT_ID,
    &quot;authorization&quot;: f&quot;Bearer {token}&quot;
  }
  
  r2 = requests.get(url = URL2, params = PARAMS2)
  
  data = r2.json()
  </code></pre>
  <p>The first section of code that gets the auth token works fine, but it isn't accepted when fed into the second half, giving the following error:</p>
  <pre><code>{'error': 'Unauthorized', 'status': 401, 'message': 'OAuth token is missing'}
  </code></pre>
  <p>My question is how can I get the API to accept the auth token and process my request. Thanks in advance for any help :)</p>
  <p>Edit - Repl link to run/fork - <a href="https://replit.com/@reisu1337/TwitchAPICall" rel="nofollow noreferrer">https://replit.com/@reisu1337/TwitchAPICall</a></p>