Pinasu
September 16, 2017, 4:47pm
1
I don’t understand, what am I doing wrong?
url = "https://api.twitch.tv/kraken/channels/my_channel"
headers = {"Client-ID" : ""+ config.CLIENT_ID +"", "Authorization": "OAuth "+config.CHAN_OAUTH}
data = {"channel": {"status": "The Finalest of Fantasies"}}
response = requests.put(url=url, headers=headers, params = data)
I’m getting a 401 response error for (apparently) no reason.
george
September 16, 2017, 4:49pm
2
Does your OAuth token have the channel_editor scope?
Pinasu
September 16, 2017, 4:54pm
3
I didn’t think about that, so probably it doesn’t. How can I fix that?
george
September 16, 2017, 5:53pm
4
Request it using one of the user access token flows: https://dev.twitch.tv/docs/authentication
Pinasu
September 17, 2017, 1:13pm
5
So, I need to act like this:
url = "https://api.twitch.tv/kraken/oauth2/authorize"
params = {"Client-ID" : ""+ config.CLIENT_ID +"", "scope" : "channel_editor"}
config.resp = requests.get(url=url, headers=params)
Before setting the status as I was doing before.
Am I right?
@Pinasu - First of all, what version are you trying to use? v3, v5 or the new twitch API?
Since you wrote
https://api.twitch.tv/kraken/channels/my_channel
It looks like its v3 or v5.
But you haven’t specified which version.
You solve a lot of obfuscated problems by setting API version.
It also dictates the authentication process.
Which doc are you following?
Pinasu
September 17, 2017, 2:26pm
7
I’m using v5, so I’m getting all my infos from here .
Looks like this end point
Pinasu
September 17, 2017, 2:30pm
9
That’s right, but I was getting Error 401.
To update other parameters: channel_editor
So I was trying to get the right token as @george suggested.
First of all, you need to add api_version=5
to your URL in that case, I think.
Or apply the header application/vnd.twitchtv.v5+json
header, as described here:
https://dev.twitch.tv/docs/v5/guides/using-the-twitch-api#requests
Also found:
401 Unauthorized. The OAuth token does not have the correct scope or does not have the required permission on behalf of the specified user
And @george is right you need channel_editor
as described here:
Authentication
channel_editor Write channel metadata (game, status, etc).
But you still gettng 401?
Since its from Python, you using app access tokens?
Apps & Authentication
Pinasu
September 17, 2017, 2:48pm
13
I just added the API version in the header and I’m trying to get the right token as follows:
url = "https://api.twitch.tv/kraken/oauth2/authorize"
params = {"Client-ID" : ""+ config.CLIENT_ID +"",
"Accept" : "application/vnd.twitchtv.v5+json",
"scope" : "openid channel_editor"}
config.resp = requests.get(url=url, headers=params)
But I’m getting “Bad request”, so I’m probably miswriting something.
Is scope
a header? I thought it was an URL query parameter. Hm.
Also which “Procedure” you using?
Apps & Authentication
Pinasu
September 17, 2017, 3:08pm
16
I’m using the OIDC Authorization Code Flow (ID Tokens and User Access Tokens) one.
Setting the scope as parameter still gives me 400 Bad request.
EDIT: I’m missing the redirect URI, so that’s probably my issue. I really don’t remember what was my URL when I registered my app, so I’m trying to figure out how to get that.
I think its found here, for your app:
Pinasu
September 17, 2017, 3:24pm
18
Yes I already found it, thanks anyway.
Setting the redirect uri as header param seemed to be the trick, so I’m now able to receive the 200 code from the token request. Now I don’t understand what am I supposed to do after obtaining my
token.
EDIT: from what I read, I need to send a new request with the “client_secret” code, sent me from the server.
system
Closed
October 17, 2017, 3:24pm
19
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.