Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Intermittent Auth Issues with Cloud Run Using google-auth-library

We are experiencing intermittent issues with our Cloud Run service authentication, which is causing disruption in our operations. Our architecture utilizes a Node.js service as our API gateway, which is not hosted on GCP. For the authentication process, we are using the google-auth-library to fetch ID tokens. These tokens are then added to our request headers as follows:

 

{
    headerKey: "X-Serverless-Authorization",
    headerValue: `Bearer ${idToken}`
}

 

However, this authentication process seems to be sporadically failing. Sometimes it works seamlessly, and at other times, it does not, leading to failed requests. This lack of reliability is causing significant issues for our service.

We have attempted to isolate the problem but have been unable to identify any patterns or causes for this inconsistent behavior. There are no apparent network issues, and the problem occurs across different devices and locations. It seems to be an issue within the Cloud Run service or the google-auth-library itself.

Any assistance in diagnosing and resolving this problem would be greatly appreciated. We would also appreciate any additional information about best practices for using the google-auth-library with Cloud Run and a non-GCP hosted Node.js API gateway.

 

0 1 260
1 REPLY 1

Hi @kombine,

Welcome to the Google Cloud Community!

Try the following troubleshooting options:

  1. Check your logs to find the error and cause of the problem. Read more about logging and viewing logs documentation.
  2. You can also get in touch with Google Cloud Support if you still can't find the cause of the problem.

For best practices in using:

  • Google Auth Library, you can read its documentation here. 
  • API gateway with Cloud Run, you can read the reference here. 

Let me know if it helped, thanks!