Currently implement a google drive API.Getting error invalid json token in laravel package.I want to upload file in after create a folder in google drive. Created app is work but after redirection nothing happen. If anyone can help.
**Tutorial Link ** : https://www.sitepoint.com/is-laravel-good-enough-to-power-a-custom-google-drive-ui/
Might be package is deprecated
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Googl;
class HomeController extends Controller
{
public function index()
{
return view('login');
}
public function login(Googl $googl, Request $request)
{
$client = $googl->client();
if ($request->has('code')) {
$client->authenticate($request->input('code'));
$token = $client->getAccessToken();
$plus = new \Google_Service_Plus($client);
$google_user = $plus->people->get('me');
$id = $google_user['id'];
$email = $google_user['emails'][0]['value'];
$first_name = $google_user['name']['givenName'];
$last_name = $google_user['name']['familyName'];
session([
'user' => [
'email' => $email,
'first_name' => $first_name,
'last_name' => $last_name,
'token' => $token
]
]);
return redirect('/dashboard')->with('message', ['type' => 'success', 'text' => 'You are now logged in.']);
} else {
$auth_url = $client->createAuthUrl();
return redirect($auth_url);
}
}
}
This should be a comment, but it seems I can't yet...
From your screenshot I can see that the problem is in AdminController.php on line 16. Can you please share this code instead. The setAccessToken()
is receiving the null
object, so the problem lies there.