Authentication Token in localhost

Hello,
I’m trying to create a twitch login system for my website!

My website is hosted @ a Windows VPS using wamp server.

I tried to create a login system, Authentication does works and I do get a code “[my redirect uri]/?code=#codehere”, but when I use this code to generate an Auth Token, It fails. I tried the same using a shared-hosting account with Hostinger and it succeeded in generating an Auth Token.

Why this cannot be done Locally?

Thanks!

This can be done locally. I’ll need some more information to help with this. What is the error message that you receive? Which endpoint are you calling? I’m assuming since you’re getting the Auth Code that your Redirect URI is set to http://localhost in the Settings page for your app?

@DallasNChains

Yes It’s this -> http://localhost/twitch/twitch.php

I get the redirected after authenticating to ->

http://localhost/twitch/twitch.php?code=codehere&scope=listofscopehere

After you get the code (as shown above), are you requesting the OAuth token? POST to the oauth2/token endpoint with the body parameters?

@DallasNChains

I just tried it with POSTman (REST Client Extension For Chrome), And I got the authentication code!

The following was returned!

{ "access_token": "stringhere", "refresh_token": "stringhere", "scope": [ "channel_check_subscription", "channel_commercial", "channel_editor", "channel_read", "channel_subscriptions", "chat_login", "user_follows_edit", "user_read" ] }

I guess maybe it’s cURL is giving me issues how ever trying echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled'; on a php script echo’s Curl: Enabled

Help appreciated!

Thanks!

Edit

I Got cURL Working By Adding
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); Before curl_exec(): Which Works Like A Charm!

New Question

Can I Get this token 1 time, save it in my mySql Data base And Use It Multiple Times? Or Do These Expire?

Thanks!

I’m guessing it is just how you’re adding the data to cURL. There is a good community thread about this over here with examples in PHP cURL: Redirect URI/Login Authentication

@DallasNChains

Solved That As Per My Edit!!

New Question

Can I Get this token 1 time, save it in my mySql Data base And Use It Multiple Times? Or Do These Expire?

Thanks!

The tokens don’t expire. For storage, I would recommend looking into best practices around security for storing OAuth tokens. These tokens can be used to take action on behalf of a user so be security-minded when handling them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.