Why am I receiving "Invalid Credentials" error in my workflow every few days?

This topic was automatically generated from Slack. You can find the original thread here.

Every few days I get this error in my workflow:
errorError: Invalid Credentials
at Gaxios._request (/var/task/node_modules/gaxios/src/gaxios.ts:169:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async OAuth2Client.requestAsync (/var/task/node_modules/google-auth-library/build/src/auth/oauth2client.js:382:18)
at async Object.listMessages (file:///var/task/user/gmail/gmail.app.mjs:243:24)
at async Object.run (file:///var/task/user/gmail_custom_oauth/sources/common/polling.mjs:64:22)
at async /var/task/index.js:122:11
at async captureObservations (/var/task/node_modules/@lambda-v2/component-runtime/src/captureObservations.js:28:5)
at async exports.main [as handler] (/var/task/index.js:60:20)

I’m sorry to hear that you’re experiencing issues with your workflow. The error message you provided indicates that there’s an issue with the credentials being used for the Gmail API. To resolve this issue, please try the following steps: 1. Open the workflow in the Pipedream UI. 2. Find the step that uses the Gmail API and click on the connected account (Gmail or Gmail Custom OAuth) to edit the connection. 3. Re-authenticate the account to refresh the access token. If the issue persists, you may want to double-check your API credentials and ensure they are still valid. If you continue to experience issues, please visit https://pipedream.com/support for more support options.

re-authenticating works, but I want this problem from happening again. How do I permanently fix it?

I understand that re-authenticating can be a temporary solution, and you’re looking for a more permanent fix. One possible reason for the “Invalid Credentials” error could be the expiration of the access token. In some cases, the refresh token process might not be working as expected, causing the issue to reoccur. To help you find a more permanent solution, I would recommend checking the following: 1. Ensure that your Gmail API credentials (Client ID and Client Secret) are set up correctly and have the necessary permissions. 2. Make sure that your workflow is handling token refreshes properly. You can refer to Google’s OAuth 2.0 documentation for handling token refreshes: Using OAuth 2.0 to Access Google APIs  |  Authorization  |  Google for Developers If you continue to face issues, please visit https://pipedream.com/support for more support options.

this is a related thread — @U052C338AQK is looking into whether there’s a way for us to handle it, or if it’s an unavoidable constraint from Google

Thank you! I published the app in Google Console. Hopefully that solves it. Fingers crossed that I don’t run into this issue again.

Cool — please let us know if that does the trick!

Hi Nikolaev, were there any verification steps required for you to Publish the app? We’re hoping that solves the issue for you as well!