public function handleCallback(Request $request) { if (!($request->has('state') && $request->has('code'))) { throw new \Exception('Callback does not provide expected parameters.'); // TODO: Change to SSOCallbackException } $this->checkState($request->input('state')); // Throws exception if no state match in cache // get an access token $accessToken = $this->getAccessToken($request->input('code')); $charInfo = $this->getCharInfo($accessToken); // Find user or create new user. //dd($charInfo); $user = User::firstOrNew(['id' => $charInfo['CharacterID'], 'name' => $charInfo['CharacterName']]); $user->refreshToken = $this->refreshToken; $user->save(); \Cache::put('accessToken:' . $user->id, $accessToken, 15); \Auth::login($user); return true; }