OAuth authorization code flow isnt working

The OAuth authorization code flow isnt working! I made all things who write there in the docs!


But the API says 404 Page not Found! PLS Help me

This is step 3 of oAuth

You are supposed to make a HTTP POST request to this URL, your 404 Error suggests you made a HTTP GET request instead

PHP Example: https://github.com/BarryCarlyon/twitch_misc/blob/master/authentication/user_access_generator/php/index.php#L38
NodeJS Example: https://github.com/BarryCarlyon/twitch_misc/blob/master/authentication/user_access_generator/nodejs/server.js#L127

@BarryCarlyon can you tell me what a POST and GET ís? Im new. And whats that? : https://github.com/BarryCarlyon/twitch_misc/blob/master/authentication/user_access_generator/php/index.php#L38

It’s just different ways for HTTP requests to be made and generally infer that other stuff will happen when you perform a given request


GET will only send “arguments” in the “URL”

POST will do either.

GET’s are repeatable
POST’s generally are not (as different data would be POSTed each time)

POST’s also allow more/other kinds of data to be send other than the limitations of the query string that only GET allows

More reading:


@BarryCarlyon But https://id.twitch.tv/oauth2/token?client_id=CLIENTID&client_secret=SECRET&code=CODE&grant_type=authorization_code&redirect_uri=http://localhost/connect.php is a post, or not?

Thats jsut a URL… You didn’t declare what HTTP method you are using.

Or provide the code you are using to run your website/tool for generating access tokens

And how I can declare what the HTTP method is? @BarryCarlyon

In the programmingcode you have

Provide the code you are using (secrets removed) and we can take a look see.

You woriking in Node? Python? PHP? brainfuck?


Is a PHP example

OK Thanks, but how can I get the code in my url? I mean this: localhost/test.php?code=1224345231356456…

Query string parameters are found in $_GET

Notice : Undefined index: code in C:\xampp\htdocs\connect.php on line 10

Line 10: ‘code’ => $_GET[‘code’],

There there is no code to retrieve from the Querystring

A check such as

Will crush the notice

Yes and wheres now the access key @BarryCarlyon?

Instide the response to the curl request.

It’ll need to be JSON decoded and then you can exract it from the object

My JSON Decode is here

Token is in $token->access_token

Also as shown elsewhere in my example I linked to

But the http_code isnt 200

Debug your PHP code.

Spit out the response it’ll describe the error

@BarryCarlyon Recoverable fatal error : Object of class stdClass could not be converted to string in C:\xampp\htdocs\connect.php on line 26 Sorry for my many questions xD

print_r should spit it out