How to handle google one tap with laravel csrf

1.5k Views Asked by At

I tried adding google one tap on a laravel app.

    <div id="g_id_onload"
         data-client_id="{{ config('google.google_client_id') }}"
         data-login_uri="{{ route('google2.callback') }}"
         _token="{{ csrf_token() }}">
    </div>

But I still get a 419 PAGE EXPIRED with a CSRF Token mismatch exception with and without the _token parameter. How should I handle this on the post route?

2

There are 2 best solutions below

0
On BEST ANSWER

For anyone with this problem the issue is that every parameter must be preceded by data- so it has to be:

 <div id="g_id_onload"
         data-client_id="{{ config('google.google_client_id') }}"
         data-login_uri="{{ route('google2.callback') }}"
         data-_token="{{ csrf_token() }}">
</div>
0
On

how to add google one tap login in laravel

You can send the csrf token like this. Here is a detailed instruction showing on adding one tap login to laravel app. https://teachnep.com/blog/how-to-add-one-tap-login-to-laravel-project