How to Troubleshoot a Vertex AI HTTP Connection Error #963
derikfernandes
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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:
(https://i.sstatic.net/YFVaaIsx.png)
Then, I go to OAuth Playground: https://developers.google.com/oauthplayground/
I select everything that is listed under Vertex AI API.
(https://i.sstatic.net/pKZbbgfg.png)
I choose the following items in the settings:
(https://i.sstatic.net/4baTrcLj.png)
• I input the OAuth Client ID and OAuth Client Secret.
• I click on "Exchange authorization code for tokens."
• I save the Refresh Token and the Access Token.
Within the platform where I will make the HTTP request, I perform the following actions:
1º Create the following HTTP request:
Method: POST URL: https://accounts.google.com/o/oauth2/token
JSON (BODY)
{ "client_secret": "XXXXXXXXXXX", "grant_type": "refresh_token", "refresh_token": "XXXXXXXXXXX", "client_id": "XXXXXXXXXXXXXXX" } Variable for the response body: oauth
2º Create the second HTTP request:
Method: Post
URL: https://us-central1-aiplatform.googleapis.com/v1/projects/crias-mvp/locations/us-central1/publishers/google/models/gemini-1.5-pro-preview-0409:streamGenerateContent
HEADERS:: Authorization Bearer {{oauth@access_token}} Content-Type application/json
JSON(BODY): {{payload}}
Name response variable: JSON
Afterward, I simply extract the response from the JSON and process it.
As I mentioned earlier, it works initially, but after about 12 hours, it stops working.
Beta Was this translation helpful? Give feedback.
All reactions