# Is Gmail giving you a headache?

You were probably searching for a fix for that obscure Gmail error. But maybe you found something better.

Stop debugging. Start coordinating.

Qordinate acts as your intelligent layer between apps like Gmail and your life. We handle the messy API connections and coordination so you can focus on what actually matters.

# Gmail Integration Terminal Errors

## Authentication Errors

### `invalid_client`
```
Error: invalid_client
{
  "error": "invalid_client",
  "error_description": "The OAuth client was not found."
}
```

### `access_denied`
```
Error: access_denied
{
  "error": "access_denied",
  "error_description": "The user denied your request"
}
```

### `invalid_grant`
```
Error: invalid_grant
{
  "error": "invalid_grant",
  "error_description": "Bad Request"
}
```

## API Errors

### `quotaExceeded`
```
HTTP 403 Forbidden
{
  "error": {
    "errors": [\
      {\
        "domain": "usageLimits",\
        "reason": "quotaExceeded",\
        "message": "Quota exceeded for quota metric 'Queries' and limit 'Queries per minute per user' of service 'gmail.googleapis.com' for consumer 'project_number:123456789'."\
      }\
    ],
    "code": 403,
    "message": "Quota exceeded for quota metric 'Queries' and limit 'Queries per minute per user' of service 'gmail.googleapis.com' for consumer 'project_number:123456789'."
  }
}
```

### `insufficientPermissions`
```
HTTP 403 Forbidden
{
  "error": {
    "errors": [\
      {\
        "domain": "global",\
        "reason": "insufficientPermissions",\
        "message": "Insufficient Permission"\
      }\
    ],
    "code": 403,
    "message": "Insufficient Permission"
  }
}
```

### `invalidArgument`
```
HTTP 400 Bad Request
{
  "error": {
    "errors": [\
      {\
        "domain": "global",\
        "reason": "invalidArgument",\
        "message": "Invalid value for: Invalid format: 2023-13-45T25:61:61.000Z is not a valid date and time."\
      }\
    ],
    "code": 400,
    "message": "Invalid value for: Invalid format: 2023-13-45T25:61:61.000Z is not a valid date and time."
  }
}
```

## SDK-Specific Errors

### Python SDK: `google.auth.exceptions.RefreshError`
```python
Traceback (most recent call last):
  File "gmail_script.py", line 15, in <module>
    service = build('gmail', 'v1', credentials=creds)
  File "/usr/local/lib/python3.9/site-packages/googleapiclient/discovery.py", line 286, in build
    request = service._http.request(uri)
  File "/usr/local/lib/python3.9/site-packages/googleapiclient/http.py", line 907, in execute
    self._execute(num_retries)
  File "/usr/local/lib/python3.9/site-packages/googleapiclient/http.py", line 942, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 401 when requesting https://www.googleapis.com/gmail/v1/users/me/messages?alt=json returned "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.">

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "gmail_script.py", line 15, in <module>
    creds = get_credentials()
  File "gmail_script.py", line 45, in get_credentials
    creds.refresh(Request())
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})
```

### Node.js SDK: `GaxiosError`
```javascript
GaxiosError: invalid_client
    at Gaxios._request (/node_modules/gaxios/src/gaxios.ts:160:13)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Gmail.users.messages.list (/node_modules/googleapis/src/apis/gmail/v1.ts:1234:15)
    at async main (/app/index.js:23:18)
{
  response: {
    config: { url: 'https://www.googleapis.com/oauth2/v4/token', method: 'POST' },
    data: { error: 'invalid_client', error_description: 'The OAuth client was not found.' },
    status: 400,
    statusText: 'Bad Request',
    headers: {
      'content-type': 'application/json; charset=utf-8',
      'cache-control': 'no-cache, no-store, max-age=0, must-revalidate',
      'pragma': 'no-cache',
      'expires': 'Mon, 01 Jan 1990 00:00:00 GMT'
    }
  }
}
```

## Connection Errors

### `timeout`
```
Error: timeout of 30000ms exceeded
    at createError (/node_modules/axios/lib/core/createError.js:16:15)
    at Timeout.handleTimeout [as _onTimeout] (/node_modules/axios/lib/adapters/http.js:280:16)
    at listOnTimeout (timers.js:557:17)
    at processTimers (timers.js:500:7)
```

## Rate Limiting

### `userRateLimitExceeded`
```
HTTP 429 Too Many Requests
{
  "error": {
    "errors": [\
      {\
        "domain": "usageLimits",\
        "reason": "userRateLimitExceeded",\
        "message": "User-rate limit exceeded. Retry after 2023-12-07T15:30:00.000Z"\
      }\
    ],
    "code": 429,
    "message": "User-rate limit exceeded. Retry after 2023-12-07T15:30:00.000Z"
  }
}
```
