# Oauth2

The OAuth2 service collection provides operations for managing OAuth2 access tokens used to authenticate with the CrowdStrike API. All API requests require a valid bearer token generated through this collection. Use these operations to generate new access tokens and revoke previously issued tokens before their standard 30-minute expiry.

2 operations in this service collection.

## Operations

- **oauth2AccessToken** (POST `/oauth2/token`) — Generate an OAuth2 access token
- **oauth2RevokeToken** (POST `/oauth2/revoke`) — Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan.

---

## oauth2AccessToken

Generate an OAuth2 access token

**POST** `/oauth2/token`

### Parameters

- **client_id** (formData string) — The API client ID to authenticate your API requests. For information on generating API clients, see [API documentation inside Falcon](https://falcon.crowdstrike.com/support/documentation/1/crowdstrike-api-introduction-for-developers).
- **client_secret** (formData string) — The API client secret to authenticate your API requests. For information on generating API clients, see [API documentation inside Falcon](https://falcon.crowdstrike.com/support/documentation/1/crowdstrike-api-introduction-for-developers).
- **member_cid** (formData string) — For MSSP Master CIDs, optionally lock the token to act on behalf of this member CID

### Example (Python)

```python
from falconpy import OAuth2

falcon = OAuth2(client_id=CLIENT_ID,
                client_secret=CLIENT_SECRET
                )

response = falcon.token(alter_state=boolean)
print(response)
```

### Response

```json
{
  "access_token": "string",
  "expires_in": 0,
  "id_token": "string",
  "issued_token_type": "string",
  "refresh_token": "string",
  "scope": "string",
  "token_type": "string"
}
```

---

## oauth2RevokeToken

Revoke a previously issued OAuth2 access token before the end of its standard 30-minute lifespan.

**POST** `/oauth2/revoke`

### Parameters

- **client_id** (formData string) — The OAuth2 client ID you are revoking the token for.
- **token** (formData string) — The OAuth2 access token you want to revoke. Include your API client ID and secret in basic auth format (`Authorization: basic <encoded API client ID and secret>`) in your request header.

### Example (Python)

```python
from falconpy import OAuth2

falcon = OAuth2(client_id=CLIENT_ID,
                client_secret=CLIENT_SECRET
                )

response = falcon.revoke(client_id="string",
                         token="string",
                         alter_state=boolean)
print(response)
```

### Response

```json
{
  "errors": [
    {
      "code": 0,
      "id": "string",
      "message": "string"
    }
  ],
  "meta": {
    "pagination": {
      "limit": 0,
      "offset": 0,
      "total": 0
    },
    "powered_by": "string",
    "query_time": 0.0,
    "trace_id": "string",
    "writes": {
      "resources_affected": 0
    }
  }
}
```
