title: How to use Firebase Auth's Google Sign-In option with Cypress.io
body: <p>I need help using Google Sign-In when testing my Angular 6 app with Cypress. It can't use the sign-in popup, and so I'm trying to follow Cypress' advice to "always use <code>cy.request()</code> to talk to 3rd party servers via their APIs." That's from <a href="https://docs.cypress.io/guides/references/best-practices.html#Visiting-external-sites" rel="nofollow noreferrer">https://docs.cypress.io/guides/references/best-practices.html#Visiting-external-sites</a> which then points us to this example: <a href="https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/logging-in__single-sign-on/cypress/integration/logging-in-single-sign-on-spec.js" rel="nofollow noreferrer">https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/logging-in__single-sign-on/cypress/integration/logging-in-single-sign-on-spec.js</a> - more info on how to do this is seen at minute 23 in a presentation by the Cypress author: <a href="https://www.youtube.com/watch?v=5XQOK0v_YRE" rel="nofollow noreferrer">https://www.youtube.com/watch?v=5XQOK0v_YRE</a></p>
  
  <p>I'm taking the video solution and trying to modify it for Firebase Auth according to <a href="https://firebase.google.com/docs/auth/web/google-signin#advanced-authenticate-with-firebase-in-nodejs" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/web/google-signin#advanced-authenticate-with-firebase-in-nodejs</a> but I'm getting stuck on how to obtain the proper <code>id_token</code> and so far I have this code in my commands.js file:</p>
  
  <pre><code>Cypress.Commands.add('login', () =&gt; {
    var id_token = ___?____;
    cy.request({
      method: 'POST',
      url: 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=[API_KEY]',
      body: {
        "requestUri": "http://localhost:3500",
        "postBody": `id_token=${id_token}&amp;providerId=google.com`,
        "returnSecureToken": true,
        "returnIdpCredential": true
      }
    })
  })
  </code></pre>
  
  <p>I believe I need to use a different API to initiate the login and request user credentials, which will include the id_token, and so I tried <a href="https://firebase.google.com/docs/auth/web/google-signin#advanced-authenticate-with-firebase-in-nodejs" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/web/google-signin#advanced-authenticate-with-firebase-in-nodejs</a> but am not yet skilled enough to pull in external js files (<a href="https://apis.google.com/js/platform.js" rel="nofollow noreferrer">https://apis.google.com/js/platform.js</a>) into Node (This is probably not possible in js files the way it is in html). Using this package: <a href="https://github.com/google/google-auth-library-nodejs" rel="nofollow noreferrer">https://github.com/google/google-auth-library-nodejs</a> may be my next attempt. Is there anyone who can pick it up from here?</p>
  
  <p>Similar question at <a href="https://stackoverflow.com/questions/48735570/is-it-possible-to-use-cypress-e2e-testing-with-a-firebase-auth-project">Is it possible to use Cypress e2e testing with a firebase auth project?</a> - but they are signing in  with user and pass.</p>