My request flow is :
1.HTTP python client (a script) => 2. GCP API gateway => 3. validate request against firebase => 4. if request valid call cloud function v2 (cloud run)
Python script is generating ID token from refresh token by using 'https://securetoken.googleapis.com/v1/token. And doing a request to API gateway using it.
API gateway config is al follow.
swagger: "2.0"
info:
title: Test
description: API to read validated token details
version: 1.0.0
paths:
/test:
get:
x-google-backend:
address: URL TO cloud function
responses:
"200":
schema:
$ref: '#/definitions/UserDetails'
description: Successful response
description: Returns details.
operationId: testID
summary: Get details from xyz
security:
- firebase: []
.
.
.
definitions:
UserDetails:
title: Root Type for UserDetails
description: User details object created from information in headers
type: object
properties:
userId:
type: string
email:
type: string
securityDefinitions:
firebase:
flow: implicit
authorizationUrl: ''
scopes: {}
type: oauth2
x-google-issuer: "https://securetoken.google.com/*********"
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
x-google-audiences: "******"
- This flow works fine but in between API gateway throws an error 500: Here are logs from gateway
{
"insertId": "8310ad5-bf4-43b-966-d94485090890563961239@a1",
"jsonPayload": {
"http_status_code": 500,
"location": "us-central1",
"api_version": "1.0.0",
"api_name": "removed",
"producer_project_id": "removed",
"service_agent": "ESPv2/2.35.0",
"log_message": "removed",
"response_code_detail": "via_upstream",
"timestamp": 1664181080.6733284,
"api_key_state": "NOT CHECKED",
"api_method": "removed"
},
"httpRequest": {
"requestMethod": "POST",
"requestUrl": "/test",
"requestSize": "5411",
"status": 500,
"responseSize": "599",
"remoteIp": "600:1900:200:a3::16",
"latency": "0.009s",
"protocol": "http"
},
"resource": {
"type": "api",
"labels": {
"method": "removed",
"version": "1.0.0",
"service": "removed",
"project_id": "removed",
"location": "us-central1"
}
},
"timestamp": "2022-09-26T08:31:20.673328479Z",
"severity": "ERROR",
"logName": "removed"
}
Note : The client script is scheduled from different places parallely.
Anyone knows root cause ? issue is coming randomly, like sometime for 24 hours it wont come, suddenly it comes, and comes after few minutes again...