> ## Documentation Index
> Fetch the complete documentation index at: https://pipedream.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate OAuth Token

> Learn how to generate an OAuth access token to authenticate requests to the Pipedream API

<Note>
  If using [one of the available SDKs](/connect/api-reference/introduction#available-sdks) in TypeScript, Python, or Java, the OAuth access token is automatically generated (and refreshed) for you when you initialize the client.
</Note>

**Create an OAuth client to get your client ID and secret:**

1. Visit the [API settings](https://pipedream.com/settings/api) for your Pipedream workspace.
2. Click the **New OAuth Client** button.
3. Name your client and click **Create**.
4. Copy the client secret. **It will not be accessible again**. Click **Close**.
5. Copy the client ID from the list.

<Info>
  Read more in the [Authentication](/connect/api-reference/authentication) section.
</Info>

## OAuth scopes

You can optionally specify a `scope` parameter in the request body to limit the access token to specific operations. The `scope` parameter accepts a space-separated list of scopes.

If no scope is specified, the token defaults to `*` (full access).

**Example request with scopes:**

```bash theme={null}
curl -X POST https://api.pipedream.com/v1/oauth/token \
  -H 'Content-Type: application/json' \
  -d '{
    "grant_type": "client_credentials",
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "scope": "connect:accounts:read connect:accounts:write"
  }'
```

<Info>
  View the full list of available scopes in the [Authentication](/connect/api-reference/authentication#oauth-scopes) section.
</Info>


## OpenAPI

````yaml post /v1/oauth/token
openapi: 3.0.4
info:
  version: 2.0.0
  title: Pipedream REST API
servers:
  - url: https://api.pipedream.com
security: []
paths:
  /v1/oauth/token:
    post:
      summary: Create OAuth token
      description: Exchange OAuth credentials for an access token
      operationId: createOauthToken
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOAuthTokenOpts'
      responses:
        '200':
          description: token created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOAuthTokenResponse'
        '429':
          description: too many requests
          headers:
            Retry-After:
              description: Number of seconds until the rate limit resets
              schema:
                type: integer
            X-RateLimit-Limit:
              schema:
                type: integer
              description: The rate limit threshold
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Number of requests remaining (always 0 when throttled)
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix timestamp when the rate limit resets
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Throttled
      x-codeSamples:
        - lang: java
          label: Java SDK
          source: >
            package com.example.usage;


            import com.pipedream.api.BaseClient;

            import
            com.pipedream.api.resources.oauthtokens.requests.CreateOAuthTokenOpts;


            public class Example {
              public static void main(String[] args) {
              BaseClient client = BaseClient.withCredentials("<clientId>", "<clientSecret>")
                .build()
              ;

              client.oauthTokens().create(
                CreateOAuthTokenOpts
                .builder()
                .clientId("client_id")
                .clientSecret("client_secret")
                .build()
              );
              }
            }
        - lang: python
          label: Python SDK
          source: |
            from pipedream import Pipedream

            client = Pipedream(
              project_id="YOUR_PROJECT_ID",
              client_id="YOUR_CLIENT_ID",
              client_secret="YOUR_CLIENT_SECRET",
            )
            client.oauth_tokens.create(
              client_id="client_id",
              client_secret="client_secret",
            )
        - lang: typescript
          label: TypeScript SDK
          source: |
            import { PipedreamClient } from "@pipedream/sdk";

            const client = new PipedreamClient({
              clientId: "YOUR_CLIENT_ID",
              clientSecret: "YOUR_CLIENT_SECRET",
              projectEnvironment: "YOUR_PROJECT_ENVIRONMENT",
              projectId: "YOUR_PROJECT_ID"
            });
            await client.oauthTokens.create({
              clientId: "client_id",
              clientSecret: "client_secret"
            });
components:
  schemas:
    CreateOAuthTokenOpts:
      type: object
      description: Request object for creating an OAuth token
      required:
        - grant_type
        - client_id
        - client_secret
      properties:
        grant_type:
          type: string
          enum:
            - client_credentials
        client_id:
          type: string
        client_secret:
          type: string
        scope:
          type: string
          description: >-
            Optional space-separated scopes for the access token. Defaults to
            `*`.
    CreateOAuthTokenResponse:
      type: object
      description: Response object for creating an OAuth token
      required:
        - access_token
        - token_type
        - expires_in
      properties:
        access_token:
          type: string
        token_type:
          type: string
        expires_in:
          type: integer

````