Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

290
Views
missing the cookies for g_csrf_token in Google Sign in button

Looking for some help with the Google Signin Implementation:

Why am I missing the cookies for g_csrf_token listed as part of the server side response when I am using the data-callback tag in my Google Sign in button?

Thanks for your help!!

Response passed to data-callback function handleCredentialResponse(response)

{
    "clientId": "<client id>",
    "credential": "<jwt token base64encoded>",
    "select_by": "btn"
}

HTML and JS Code

<div id="g_id_onload" 
    data-client_id="<client id>"
    data-context="signin"
    data-ux_mode="popup"
    data-nonce="randomstring"
    data-auto_prompt="false"
    data-callback="handleCredentialResponse">
</div>

<div class="g_id_signin" class="button_item"
    data-type="standard"
    data-shape="pill"
    data-theme="filled_blue"
    data-text="signin_with"
    data-size="large"
    data-logo_alignment="left">
</div>

...

function handleCredentialResponse(response) {
    console.log(response); // This prints the JSON objet listed in the response above in the answer {clientId:"", credential:"", selected_by:""}
    postData('/authorize', response )
        .then(data => {
            console.log('User authorized:', data);
            
        })
        .catch(error => {
            console.error('Error:', error);
        });
}
async function postData(url = '', data = {}) {
    // Default options are marked with *
    const response = await fetch(url, {
        method: 'POST', // *GET, POST, PUT, DELETE, etc.
        mode: 'cors', // no-cors, *cors, same-origin
        cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
        credentials: 'same-origin', // include, *same-origin, omit
        headers: {
        'Content-Type': 'application/json'
        // 'Content-Type': 'application/x-www-form-urlencoded'

        },
        redirect: 'follow', // manual, *follow, error
        referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
        body: JSON.stringify(data) // body data type must match "Content-Type" header
    });
    return response; // parses JSON response into native JavaScript objects
}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!