/**
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function stepTwo(Request $request)
{
if (!Input::get('code')) {
redirect('/step_one');
}
$this->setRedirectUrl('step_two');
$session = new SpotifyWebAPI\Session($this->getClientId(), $this->getClientSecret(), $this->getRedirectUrl());
$api = new SpotifyWebAPI\SpotifyWebAPI();
try {
$session->requestAccessToken(Input::get('code'));
$accessToken = $session->getAccessToken();
$api->setAccessToken($accessToken);
$refreshToken = $session->getRefreshToken();
} catch (Exception $e) {
Log::error($e->getMessage());
return redirect('/spotify/step_one');
}
$request->session()->put('spotify.access_token', $accessToken);
$request->session()->put('spotify.access_token', $refreshToken);
$data = array('test' => 'test');
return View::make('spotify.step_two')->with('data', $data);
}