curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d u/request.json \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/endpoints/ENDPOINT_ID:explain"
const path = `https://us-central1-aiplatform.googleapis.com/v1/projects/${Constants.expoConfig.extra.VERTEX_PROJECT_ID}/locations/us-central1/endpoints/${Constants.expoConfig.extra.VERTEX_ENDPOINT_ID}:predict`;
const init = {
method: 'POST',
body: JSON.stringify(requestBody),
headers: {
Authorization: `Bearer ${Constants.expoConfig.extra.VERTEX_GCLOUD_ACCESS_TOKEN}`,
'Content-Type': 'application/json',
},
};
const response = await fetch(path, init);
Note: The following command assumes that you have logged in to the gcloud CLI with your user account by running gcloud init or gcloud auth login, or by using Cloud Shell, which automatically logs you into the gcloud CLI. You can check the currently active account by running gcloud auth list.
Is it correct that I want to call gcloud auth login basically once, when the server is initialized so that any of my users can use the feature on the mobile app, or does this need to be called each time a request is made to the gcloud API? Then the gcloud auth print-access-token gets called for each API request.
Hello @lucksp,
Welcome to Google Cloud Community!
Instead of using gcloud, you can use api keys or client libraries so users will be able to authenticate. If you encounter any errors while working on this, don't hesitate to post back here we are delighted to try and help.
Thanks!