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

# Link OAuth provider

> Retrieve link provider OAuth via the Junction API. Requires authentication with your team API key.

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
       --url {{BASE_URL}}/v2/link/provider/oauth/{oauth_provider} \
       --header 'Accept: application/json' \
       --header 'Content-Type: application/json' \
       --header 'x-vital-link-token: <VITAL-LINK-TOKEN>'
  ```

  ```typescript TypeScript theme={null}
  import { JunctionClient, JunctionEnvironment, OAuthProviders } from "@junction-api/sdk";

  const client = new JunctionClient({
      apiKey: "YOUR_API_KEY",
      environment: JunctionEnvironment.Sandbox,
  });

  const tokenResponse = await client.link.token({ userId: "<user_id>" });

  const data = await client.link.generateOauthLink({
      oauthProvider: OAuthProviders.Oura,
      vitalLinkToken: tokenResponse.linkToken,
  });
  ```

  ```python Python theme={null}
  from junction import Junction, OAuthProviders
  from junction.environment import JunctionEnvironment

  client = Junction(
      api_key="YOUR_API_KEY",
      environment=JunctionEnvironment.SANDBOX,
  )

  token_response = client.link.token(user_id="<user_id>")

  data = client.link.generate_oauth_link(
      OAuthProviders.OURA,
      vital_link_token=token_response.link_token,
  )
  ```

  ```java Java theme={null}
  import com.junction.api.Junction;
  import com.junction.api.core.Environment;
  import com.junction.api.resources.link.requests.GenerateOauthLinkLinkRequest;
  import com.junction.api.resources.link.requests.LinkTokenExchange;
  import com.junction.api.types.OAuthProviders;

  Junction client = Junction.builder()
      .apiKey("YOUR_API_KEY")
      .environment(Environment.SANDBOX)
      .build();

  var tokenResponse = client.link().token(
      LinkTokenExchange.builder()
          .userId("<user_id>")
          .build()
  );

  var data = client.link().generateOauthLink(
      OAuthProviders.OURA,
      GenerateOauthLinkLinkRequest.builder()
          .vitalLinkToken(tokenResponse.getLinkToken())
          .build()
  );
  ```

  ```go Go theme={null}
  import (
      "context"

      junction "github.com/junction-api/junction-go"
      "github.com/junction-api/junction-go/client"
      "github.com/junction-api/junction-go/option"
  )

  c := client.NewClient(
      option.WithApiKey("YOUR_API_KEY"),
      option.WithBaseURL(junction.Environments.Sandbox),
  )

  tokenResponse, err := c.Link.Token(context.TODO(), &junction.LinkTokenExchange{
      UserId: "<user_id>",
  })
  if err != nil {
      return err
  }

  response, err := c.Link.GenerateOauthLink(context.TODO(), &junction.GenerateOauthLinkLinkRequest{
      OauthProvider:  junction.OAuthProvidersOura,
      VitalLinkToken: &tokenResponse.LinkToken,
  })
  if err != nil {
      return err
  }
  fmt.Printf("Received data %s\n", response)
  ```
</RequestExample>


## OpenAPI

````yaml GET /v2/link/provider/oauth/{oauth_provider}
openapi: 3.1.0
info:
  title: Junction API
  description: https://docs.junction.com/
  version: 0.4.483
servers:
  - url: https://api.us.junction.com
    x-fern-server-name: Production
  - url: https://api.eu.junction.com
    x-fern-server-name: ProductionEU
  - url: https://api.sandbox.us.junction.com
    x-fern-server-name: Sandbox
  - url: https://api.sandbox.eu.junction.com
    x-fern-server-name: SandboxEU
security:
  - apiKeyAuth: []
paths:
  /v2/link/provider/oauth/{oauth_provider}:
    get:
      tags:
        - link
      summary: Generate Oauth Link Endpoint
      description: This endpoint generates an OAuth link for oauth provider
      operationId: generate_oauth_link
      parameters:
        - name: oauth_provider
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/OAuthProviders'
        - name: x-vital-link-token
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Vital-Link-Token
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Source'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security: []
components:
  schemas:
    OAuthProviders:
      type: string
      enum:
        - oura
        - fitbit
        - garmin
        - strava
        - wahoo
        - ihealth
        - withings
        - google_fit
        - dexcom_v3
        - polar
        - cronometer
        - omron
        - whoop_v2
        - my_fitness_pal_v2
        - ultrahuman
        - runkeeper
      title: OAuthProviders
      description: ℹ️ This enum is non-exhaustive.
    Source:
      properties:
        name:
          type: string
          title: Name
        slug:
          type: string
          title: Slug
        description:
          type: string
          title: Description
        logo:
          type: string
          title: Logo
        group:
          anyOf:
            - type: string
            - type: 'null'
          title: Group
        oauth_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Oauth Url
        auth_type:
          anyOf:
            - $ref: '#/components/schemas/SourceAuthType'
            - type: 'null'
          default: oauth
          description: ℹ️ This enum is non-exhaustive.
        source_type:
          anyOf:
            - $ref: '#/components/schemas/SourceType'
            - type: 'null'
          default: device
          description: ℹ️ This enum is non-exhaustive.
        is_active:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Active
          default: true
        backfill_num_days:
          anyOf:
            - type: integer
            - type: 'null'
          title: Backfill Num Days
        id:
          type: integer
          title: Id
      type: object
      required:
        - name
        - slug
        - description
        - logo
        - id
      title: Provider
      example:
        auth_type: oauth
        description: Garmin Watches
        id: 1
        logo: https://garmin.com
        name: Garmin
        oauth_url: https://garmin_aouth_url.com
        slug: garmin
    HTTPValidationError:
      properties:
        detail:
          title: Detail
      type: object
      title: HTTPValidationError
    SourceAuthType:
      type: string
      enum:
        - oauth
        - team_oauth
        - sdk
        - password
        - email
        - app
        - ''
      title: SourceAuthType
      x-fern-enum:
        '':
          name: Empty
      description: ℹ️ This enum is non-exhaustive.
    SourceType:
      type: string
      enum:
        - app
        - ble
        - device
        - lab
        - provider
      title: SourceType
      description: ℹ️ This enum is non-exhaustive.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-vital-api-key
      description: Vital Team API Key

````