I am creating a php laravel application that requires google oauth to work. So I created the following function:
function auth(){
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("https://www.googleapis.com/auth/adsense.readonly");
$authUrl = $client->createAuthUrl();
return "<a href=\"$authUrl\">Connect Me</a>";
}
Now I want to access this $client variable when the user comes back on my site. Since my Session becomes empty after the redirect, I can't use that. (maybe something to do with the response being in HTTPS).
The two options I have considered are: 1) Cookies 2) Making the redirect url have the session id as a param (not sure if this can work)
Is there any standard way to achieve this?
Session::put('client', $client);before returning$authUrl. On the other side, I do$client = Session::get('client');but this comes out to be empty. Could this be because my auth() function is served over http and the redirect response uri is a different url that comes over https?