MD. HASAN MUNSI
MD. HASAN MUNSI

Reputation: 43

How to resolve Kreait \ Firebase \ Exception \ ApiException (400) invalid_grant for firebase

I am facing invalid_grant problem again and again. I am trying to implement firebase to my laravel project.

namespace App\Http\Controllers;
use Kreait\Firebase;
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
use Kreait\Firebase\Database;

.............................

And This is my store function:

..............................

public function store(Request $request)
    {
        $serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/resturant-f7e23-firebase-adminsdk-sziig-4bd11864d7.json');
        $firebase = (new Factory)
            ->withServiceAccount($serviceAccount)
            ->withDatabaseUri('https://resturant-f7e23.firebaseio.com/')
            ->create();

        $db = $firebase->getDatabase();

        $db->getReference('reserves/'.'1')
        ->set([
            'name' => 'John',
            'emails' => '[email protected]',
            'website' => 'http://john.com',
            ]);

        return ('You did it');
    }

firebase invalid_grant

Upvotes: 0

Views: 2617

Answers (1)

MD. HASAN MUNSI
MD. HASAN MUNSI

Reputation: 43

Just Update your device's date and time. It will be fixed. The problem was with my machine's date time. If you are behind from the time zone you are in, the invalid_grant error will occur.

Upvotes: 3

Related Questions