phplaravelpostcsrfgoogle-one-tap

How to handle google one tap with laravel csrf


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?


Solution

  • 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>