I am trying to connect via HTTP request to Google Vertex AI and can successfully connect for a while. However, after a few hours (more than 12 hours), the following error appears:
{ "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "CREDENTIALS_MISSING", "domain": "googleapis.com", "metadata": { "method": "google.cloud.aiplatform.v1.PredictionService.GenerateContent", "service": "aiplatform.googleapis.com" } } ] } }
oauth { "error": "invalid_grant", "error_description": "reauth related error (invalid_rapt)", "error_uri": "https://support.google.com/a/answer/9368756", "error_subtype": "invalid_rapt" } oauth@access_token
The method I am using involves creating credentials within the console. I select the Vertex AI API and create credentials with the following characteristics:
Then, I go to OAuth Playground: https://developers.google.com/oauthplayground/
I select everything that is listed under Vertex AI API.
I choose the following items in the settings:
Within the platform where I will make the HTTP request, I perform the following actions:
The token might expire. You probably want to try other authconfig type, like service account.
Hi @deriklfs,
I agree with @fengwan. Tokens are short-lived. With this, you may need to refresh your token or generate a token. You may consider running $gcloud auth print-access-token using the gcloud CLI. Once done, use this token in your Authorization HTTP header (Authorization: Bearer {TOKEN}).
Hope this helps.