title: TypeError: jwt.split is not a function at OAuth2Client.verifySignedJwtWithCertsAsync Node package: google-auth-library
body: <p>The react-google-login from the client react app sends the response back to the Nodejs server with a post request-<br />
  client code -</p>
  <pre class="lang-js prettyprint-override"><code>import axios from 'axios';
  import React, { Component } from 'react';
  import GoogleLogin from 'react-google-login';
  import refreshTokenSetup from '../../utils/refreshToken';
  
  const clientId =
   'xxxxxx-xfdgsdjg3gfxxxxxxxxxxx.apps.googleusercontent.com';
  
  
  function Login() {
   const onSuccess = (res) =&gt; {
     console.log('Login Success: currentUser:', res.profileObj);
     alert(
       `Logged in successfully welcome ${res.profileObj.name} . \n See console for full profile object.`
     );
     axios
       .post('http://localhost:5000/auth/checkToken', { body: res.tokenId })
       .then()
       .catch((err) =&gt; {
         console.log(err);
       });
   };
  
   const onFailure = (res) =&gt; {
     console.log('Login failed: res:', res);
     alert(
       `Failed to login.  Please ping this to repo owner twitter.com/sivanesh_fiz`
     );
   };
  
   return (
     &lt;div&gt;
       &lt;GoogleLogin
         clientId={clientId}
         buttonText='Login'
         onSuccess={onSuccess}
         onFailure={onFailure}
         cookiePolicy={'single_host_origin'}
         style={{ marginTop: '100px' }}
         isSignedIn={true}
       /&gt;
     &lt;/div&gt;
   );
  }
  
  export default Login;
  
  </code></pre>
  <p>the backend route-</p>
  <pre class="lang-js prettyprint-override"><code>const { OAuth2Client } = require('google-auth-library');
  const key = require('../config/key');
  module.exports = {
    checkToken: (req, res, next) =&gt; {
      console.log('checking begins...', req.body);
  
      const client = new OAuth2Client(key.GOOGLE_CLIENT_ID);
      async function verify() {
        const ticket = await client.verifyIdToken({
          idToken: req.body,
          audience: key.GOOGLE_CLIENT_ID, // Specify the CLIENT_ID of the app that accesses the backend
          // Or, if multiple clients access the backend:
          //[CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3]
        });
        const payload = ticket.getPayload();
        const userid = payload['sub'];
        // If request specified a G Suite domain:
        // const domain = payload['hd'];
      }
      verify().catch(console.error);
    },
  };
  
  </code></pre>
  <p>The above code is in reference to official Google Documentation available at- <a href="https://developers.google.com/identity/sign-in/web/backend-auth" rel="nofollow noreferrer">https://developers.google.com/identity/sign-in/web/backend-auth</a></p>
  <p>Now everything works fine, user is signed in in the client side, the tokenId is sent back to the server and can be verified by console logging it, even on <a href="https://jwt.io/" rel="nofollow noreferrer">https://jwt.io/</a> but the following error is shown-</p>
  <pre><code>TypeError: jwt.split is not a function
      at OAuth2Client.verifySignedJwtWithCertsAsync (E:\Projects\EAbackend\node_modules\google-auth-library\build\src\auth\oauth2client.js:528:30)
      at OAuth2Client.verifyIdTokenAsync (E:\Projects\EAbackend\node_modules\google-auth-library\build\src\auth\oauth2client.js:394:34)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at async verify (E:\Projects\EAbackend\middleware\auth.js:9:22)
  </code></pre>