Basic Twitch Connect OAuth Help

The problem that you’re having is that you first need to link off to the page where you’re able to get them to authenticate your application.

First off you’re going to need to make sure that your $client_id and $client_secret are the same as listed on the TwitchTV side of things.

Once you assure that you’re going to need to call authenticate() inside an href of an html link tag.

<a href="<?php echo $twitchtv->authenticate(); ?>">Authenticate here</a>

now you should be brought to TwitchTV to authenticate the application. Make sure that you know what your redirect url is because that’s where you’ll need the code to handle getting the access token. So once you’re returned you should see in the URL a GET variable tagged onto the end of the url (it’s what follows ?code= you’ll want that value so in this case $code = $_GET['code'];. If you don’t see it in the url than you won’t get any output because that value doesn’t exist.

Now you should be able to get into the if statement and receive the access token via the $authCode = $twitchtv->get_access_toke($code);

Then your echo should work. It should work if you A) went to TwitchTV and got redirected B) have a ?code= in the url. For safe keeping I’d store the value of that $_GET and then the access token itself in a database. If you’re worried about people stealing your access tokens then you’d want to store them encrypted and then decrypt them in your code.

Hopefully that helps. I’m not sure how to better explain it. If it doesn’t work than post your code here what file they’re in, etc. and I’ll try to see what’s up with it.