title: Invalid Grant nodemon in NextJS and Typescript
body: <p>I am receiving an invalid grand error from nodeMailer in NextJS, also Typescript is underlining one of the lines, the strange thing is that it worked on one of my other projects</p>
  <p>this is the code</p>
  <pre><code>const sendEmailToGuestsHandler: NextApiHandler = async (req, res) =&gt; {
    const REDIRECT_URI = &quot;https://developers.google.com/oauthplayground/&quot;;
    const { CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN } = process.env;
  
    if (!CLIENT_ID || !CLIENT_SECRET || !REFRESH_TOKEN) {
      return res.status(404).json({ error: &quot;Invalid secrets&quot; });
    }
    const oauth2Client = new google.auth.OAuth2(
      CLIENT_ID,
      CLIENT_SECRET,
      REDIRECT_URI
    );
    oauth2Client.setCredentials({ refresh_token: REFRESH_TOKEN });
    const accessToken = await oauth2Client.getAccessToken();
  
    const emailTransport = createTransport({
      service: &quot;gmail&quot;,
      auth: {
        type: &quot;OAuth2&quot;,
        user: &quot;xf@xfaang.com&quot;,
        clientId: CLIENT_ID,
        clientSecret: CLIENT_SECRET,
        refreshToken: REFRESH_TOKEN,
        accessToken: accessToken,
      },
    });
  
    const mailOptions = {
      from: '&quot;John&quot; &lt;xfre@example.com&gt;',
      to: &quot;john@gmail.com&quot;,
      subject: `estimation report`,
      attachments: [
        {
          filename: `_estimation_report.pdf`,
          contentType: &quot;application/pdf&quot;,
          content: &quot;&lt;div&gt;elo&lt;/div&gt;&quot;,
          encoding: &quot;base64&quot;,
        },
      ],
      text: &quot;&lt;div&gt;elo&lt;/div&gt;&quot;,
      html: &quot;&lt;div&gt;elo&lt;/div&gt;&quot;,
    };
  
    await emailTransport.sendMail(mailOptions);
  </code></pre>
  <p>red underline is under</p>
  <pre><code>service: &quot;gmail&quot;,
  </code></pre>
  <p>And I am not sure if this is the reason why I'm getting</p>
  <pre><code>error - Error: invalid_grant
  </code></pre>
  <p>in the d.ts file there is a lot of overloads of this function, previously I did not use TS and followed this tutorial <a href="https://www.youtube.com/watch?v=-rcRf7yswfM&amp;list=LL&amp;index=9" rel="nofollow noreferrer">https://www.youtube.com/watch?v=-rcRf7yswfM&amp;list=LL&amp;index=9</a> seems more legit than auth via login and password.</p>