Hey i’m having a weird problem while trying to get a userID i keep getting the response from twitch saying
OAuth token is missing
However i do give it a correct Oauth token
def getUserID(Username, OAUTH):
HEADERS = {'client_id': CLIENT_ID, 'Authorization': 'Bearer ' + OAUTH}
URL = BASE_URL + "users?login="
print(URL)
try:
req = requests.get(URL, HEADERS)
print(req)
jsondata = req.json()
print(jsondata)
except Exception as e:
print("Error getting ID for: ", Username, "Caused by: ", e)
any advice or things i’ve done wrong?
This is python requests yes?
Sadly not still the same response
And OAUTH is actually a token?
heres a similar example
import requests
client_id = ''
client_secret = ''
streamer_name = ''
body = {
'client_id': client_id,
'client_secret': client_secret,
"grant_type": 'client_credentials'
}
r = requests.post('https://id.twitch.tv/oauth2/token', body)
#data output
keys = r.json();
print(keys)
headers = {
'Client-ID': client_id,
This file has been truncated. show original
This is the code that gets the OAuth
OAUTHHEADERS = {'client_id': CLIENT_ID, 'client_secret': CLIENT_SECRET, 'grant_type': 'client_credentials'}
OAUTHURL = "https://id.twitch.tv/oauth2/token"
def getOauth():
try:
req = requests.post(OAUTHURL, OAUTHHEADERS)
print(req.json())
jsondata = req.json()
if 'access_token' in jsondata:
print(jsondata['access_token'])
except Exception as e:
print(e)
For the getting a token you need to POST as body, this looks like you are sending headers instead, and thus not getting a token out as it’s failing.
(My python is a tad rusty)
It returns what looks to be an oauth token i would send it but idk if thats a security issue or not
never leak your token no.
If the API says it’s missing then your code might not be propgating the generated token to the other function(s)
You was right and i see the problem i forgot to tell my getOAuth function to return the oauth thanks It’s useful to have 2 sets of heads at the problem but i am still getting the problem even if it is passing the OAuth token through
I don’t know if this will help but this is what the headers that are added on to the request
{'client-id': 'REDACTED', 'Authorization': 'Bearer REDACTED'}
After more and more searching i can not figure out what i have done wrong everything seems to be coded correctly
A post was split to a new topic: oAuth issue with nodeJS
system
Closed
May 25, 2021, 12:26pm
16
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.