skmetaly / laravel-twitch-restful-api

Laravel implementation of the restful api provided by Twitch.tv
MIT License
8 stars 4 forks source link

keep token stored #4

Open olszak94 opened 8 years ago

olszak94 commented 8 years ago

how can i keep token stored, so i don't have to do redirect each time to authenticate request?

Right now i have routes /twitch and /twitch/redirect i have to head to 2nd route first so it gets the code and then redirects to /twitch, otherwise if i access /twitch w/o redirecting, it throws exception that it need to be authenticated (probably because of missing token)

Mobius1 commented 8 years ago

Store the token in a session variable:

$token  = TwitchApi::requestToken(Input::get('code'));
session(['token' => $token]);

Then simply recall the token later:

$token = session('token');