---
title: "Initiate OAuth flow for Google Earth Engine authentication."
method: POST
path: "/api/v1/user/me/gee-oauth/initiate"
---

# Initiate OAuth flow for Google Earth Engine authentication.

`POST /api/v1/user/me/gee-oauth/initiate`

## Request

- Base URL: `https://api.trends.earth/api/v1`
- URL: `https://api.trends.earth/api/v1/api/v1/user/me/gee-oauth/initiate`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/trends/apis/trends-earth-api/docs/api/v1/user/me/gee-oauth/initiate/post.ts> (a function with typed inputs; its response is checked against the schema)

**Authentication**: JWT token required
**Authorization**: Any authenticated user

**Prerequisites**:
- Server must have Google OAuth client credentials configured
- Environment variables GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET
  required

**Response Schema**:
```json
{
  "data": {
    "auth_url": "https://accounts.google.com/o/oauth2/auth?...",
    "state": "random-state-string-for-csrf-protection"
  }
}
```

**Response Fields**:
- `auth_url`: URL to redirect user to for Google OAuth authorization
- `state`: CSRF protection token to include in callback

**OAuth Flow Steps**:
1. Call this endpoint to get authorization URL
2. Redirect user to the auth_url
3. User authorizes your application in Google
4. User is redirected back with authorization code
5. Call `/user/me/gee-oauth/callback` with the code and state

**Error Responses**:
- `401 Unauthorized`: JWT token required or invalid
- `500 Internal Server Error`: OAuth not configured or server error

## Request body

- object

## Response `200`

Success

- object

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `500`: Internal Server Error

---

[API](https://skmtc.dev/trends/apis/trends-earth-api.md) - [All operations](https://skmtc.dev/trends/apis/trends-earth-api/llms.txt) - [OpenAPI document](https://skmtc.dev/trends/apis/trends-earth-api/revisions/0b75d1e065e1?raw)
