# GCloud CLI Commands to Fix Vertex AI Permissions
## Quick Fix Commands
Run these commands one by one to fix the 403 permission error:
### Step 1: Grant Vertex AI User Role
```bash
gcloud projects add-iam-policy-binding amgn-app \
--member="serviceAccount:amrogen-service@amgn-app.iam.gserviceaccount.com" \
--role="roles/aiplatform.user"
```
### Step 2: Grant Vertex AI Service Agent Role (Optional but recommended)
```bash
gcloud projects add-iam-policy-binding amgn-app \
--member="serviceAccount:amrogen-service@amgn-app.iam.gserviceaccount.com" \
--role="roles/aiplatform.serviceAgent"
```
### Step 3: Verify Permissions
```bash
gcloud projects get-iam-policy amgn-app \
--flatten="bindings[].members" \
--filter="bindings.members:serviceAccount:amrogen-service@amgn-app.iam.gserviceaccount.com" \
--format="table(bindings.role)"
```
You should see:
- `roles/aiplatform.user`
- `roles/aiplatform.serviceAgent` (if you ran Step 2)
### Step 4: Check Available Vertex AI Regions
The `gcloud ai locations list` command doesn't exist. Use these common valid regions:
**Common Vertex AI Regions:**
- `us-central1` (Iowa, USA) - **Recommended - Most Common**
- `us-east1` (South Carolina, USA)
- `us-east4` (Northern Virginia, USA)
- `us-west1` (Oregon, USA)
- `us-west4` (Las Vegas, USA)
- `europe-west1` (Belgium)
- `europe-west4` (Netherlands)
- `asia-southeast1` (Singapore)
**Quick Test a Region:**
```bash
gcloud ai models list --region=us-central1 --project=amgn-app --limit=1
```
If this works, `us-central1` is available!
### Step 5: Update Vercel Environment Variable
**CRITICAL:** The location `global` is NOT valid! Update `GCP_LOCATION` in Vercel to one of the regions from Step 4.
Common options:
- `us-central1` (recommended)
- `us-east1`
- `us-west1`
## All Commands in One Script
```bash
cd garbage/linkedin-lead-mcp
chmod +x fix-permissions.sh
./fix-permissions.sh
```
## Manual Steps After Running Commands
1. **Update Vercel Environment Variable:**
- Go to Vercel Dashboard → Settings → Environment Variables
- Find `GCP_LOCATION`
- Change from `global` to `us-central1` (or another valid region from Step 4)
- Save and redeploy
2. **Wait for Redeploy** (1-2 minutes)
3. **Test Again:**
```bash
curl -X POST "https://linkedin-mcp-mocha.vercel.app/api/products/analyze" \
-H "Content-Type: application/json" \
-d '{
"api_key": "b01a98cddade43cac435ef18e6bf0ffe9937dd8fd2da7910b2b9c4b11284d471",
"name": "AmroPilot",
"website_url": "https://amropilot.com",
"description": "AmroPilot is an AI-powered content creation platform that generates human-like text. It helps content creators, marketers, and SEO professionals create engaging articles that rank, convert, and dominate search results.",
"value_proposition": "Transform your content strategy with AI that understands search intent, creates engaging articles, and optimizes for maximum visibility. Generate content that bypasses AI detection and ranks on Google.",
"target_audience": "Content creators, SEO professionals, digital marketers, content marketing agencies, bloggers, online businesses"
}' | python -m json.tool
```
## Troubleshooting
### If commands fail with "permission denied":
```bash
# Make sure you're authenticated
gcloud auth login
# Set the project
gcloud config set project amgn-app
# Verify you have admin permissions
gcloud projects get-iam-policy amgn-app --format=json | grep your-email
```
### If region doesn't exist:
```bash
# List all available regions
gcloud ai locations list --project=amgn-app
# Make sure Vertex AI API is enabled
gcloud services enable aiplatform.googleapis.com --project=amgn-app
```
### Check service account exists:
```bash
gcloud iam service-accounts describe amrogen-service@amgn-app.iam.gserviceaccount.com --project=amgn-app
```