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

# Complete OAuth sign-in

> Finish a sign-in for an OAuth variable with what the provider's redirect carried, and store its tokens on the variable. Only the caller who started the sign-in can finish it. Completing one that already finished returns the variable again. A provider refusal or a mismatch is a 400 with the reason, a missing or expired sign-in a 404, and a sign-in being completed, or for settings changed since it started, a 409.



## OpenAPI

````yaml POST /api/v1/agent-vault/variables/{variableId}/authorizations/complete
openapi: 3.0.3
info:
  title: Infisical API
  description: List of all available APIs that can be consumed
  version: 0.0.1
servers:
  - url: https://us.infisical.com
    description: Production server (US)
  - url: https://eu.infisical.com
    description: Production server (EU)
  - url: http://localhost:8080
    description: Local server
security: []
paths:
  /api/v1/agent-vault/variables/{variableId}/authorizations/complete:
    post:
      tags:
        - Agent Vault Variables
      description: >-
        Finish a sign-in for an OAuth variable with what the provider's redirect
        carried, and store its tokens on the variable. Only the caller who
        started the sign-in can finish it. Completing one that already finished
        returns the variable again. A provider refusal or a mismatch is a 400
        with the reason, a missing or expired sign-in a 404, and a sign-in being
        completed, or for settings changed since it started, a 409.
      operationId: completeAgentVaultVariableAuthorization
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: variableId
          required: true
          description: The ID of the variable.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                state:
                  type: string
                  minLength: 1
                  maxLength: 256
                  description: >-
                    The `state` value from the provider's redirect. It names the
                    sign-in, which must have been started for this variable by
                    you.
                code:
                  type: string
                  minLength: 1
                  maxLength: 4096
                  description: The `code` value from the redirect.
                iss:
                  type: string
                  maxLength: 2048
                  description: >-
                    The `iss` value from the redirect, when the authorization
                    server sends one.
                error:
                  type: string
                  maxLength: 1024
                  description: >-
                    The `error` value from the redirect, when the authorization
                    server sends one instead of a code.
                errorDescription:
                  type: string
                  maxLength: 4096
                  description: The `error_description` value from the redirect.
              required:
                - state
              additionalProperties: false
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  variable:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The ID of the variable.
                      key:
                        type: string
                        description: >-
                          The name values use to refer to the variable, as
                          `{{KEY}}`. Starts with a letter and uses only upper
                          case letters, numbers and underscores.
                      scope:
                        type: string
                        enum:
                          - global
                          - personal
                        description: >-
                          global for a variable admins set up for services, or
                          personal for one of your own, which only your personal
                          values can use and only you can see. Personal keys are
                          unique among your own variables.
                      type:
                        type: string
                        enum:
                          - text
                          - oauth
                        description: >-
                          `text` for a value services put in place of `{{KEY}}`,
                          or `oauth` for a sign-in whose access token a service
                          sends as its credential. Fixed when the variable is
                          created.
                      oauth:
                        type: object
                        properties:
                          status:
                            type: string
                            enum:
                              - connected
                              - needs-reauthorization
                              - needs-additional-scopes
                              - not-connected
                            description: >-
                              `not-connected` until a sign-in or token import,
                              or after an edit disconnected it. Then
                              `connected`, `needs-reauthorization` once the
                              provider stopped accepting the sign-in, or
                              `needs-additional-scopes` when a service needs
                              scopes the sign-in didn't grant.
                          serverUrl:
                            type: string
                            nullable: true
                            description: >-
                              An https URL Infisical discovers the provider's
                              endpoints from at each sign-in, such as an MCP
                              server's URL or the provider's issuer URL.
                          issuer:
                            type: string
                            nullable: true
                            description: >-
                              The provider's issuer, checked against the `iss`
                              of each sign-in. Only with endpoints set up by
                              hand; defaults to the origin of
                              `authorizationEndpoint`.
                          authorizationEndpoint:
                            type: string
                            nullable: true
                            description: >-
                              The provider's authorization endpoint, an https
                              URL. Send it with `tokenEndpoint`.
                          tokenEndpoint:
                            type: string
                            nullable: true
                            description: >-
                              The provider's token endpoint, an https URL. Send
                              it with `authorizationEndpoint`.
                          clientId:
                            type: string
                            nullable: true
                            description: >-
                              The client ID of your own OAuth app. Required with
                              endpoints set up by hand. Leave it out to register
                              a new client at each sign-in, for a provider that
                              supports dynamic client registration.
                          registration:
                            type: string
                            enum:
                              - dynamic
                              - manual
                            description: >-
                              `manual` when the variable uses your own OAuth
                              app, `dynamic` when each sign-in registers a
                              client.
                          tokenEndpointAuthMethod:
                            type: string
                            enum:
                              - none
                              - client_secret_basic
                              - client_secret_post
                            nullable: true
                            description: >-
                              How your OAuth app authenticates at the token
                              endpoint: `client_secret_basic`,
                              `client_secret_post` or `none`. Leave it out to
                              pick one at sign-in.
                          scopes:
                            type: array
                            items:
                              type: string
                            description: >-
                              The scopes each sign-in asks for. At least one is
                              required with endpoints set up by hand.
                          resource:
                            type: string
                            nullable: true
                            description: >-
                              The resource indicator (RFC 8707) to send with
                              each request, an https URL. Only with endpoints
                              set up by hand.
                          clientName:
                            type: string
                            nullable: true
                            description: >-
                              The name a registered client shows on the
                              provider's consent screen. Defaults to the
                              project's name. Not used with your own OAuth app.
                          redirectUri:
                            type: string
                            nullable: true
                            description: >-
                              Your own callback for sign-in links made through
                              the API, an https URL. Register it with your OAuth
                              app. Leave it out to use Infisical's callback
                              page.
                          connection:
                            type: object
                            properties:
                              issuer:
                                type: string
                                description: The issuer the tokens came from.
                              grantedScopes:
                                type: array
                                items:
                                  type: string
                                description: The scopes the provider granted.
                              requiredScopes:
                                type: array
                                items:
                                  type: string
                                description: >-
                                  Scopes a service reported it needs that the
                                  sign-in didn't grant.
                              expiresAt:
                                type: string
                                nullable: true
                                description: >-
                                  When the access token expires, if the provider
                                  said. Infisical refreshes it before then.
                              authorizedAt:
                                type: string
                                nullable: true
                                description: >-
                                  When the variable was last signed in or given
                                  tokens.
                              lastError:
                                type: string
                                nullable: true
                                description: Why the last refresh failed, when it did.
                            required:
                              - issuer
                              - grantedScopes
                              - requiredScopes
                              - expiresAt
                              - authorizedAt
                              - lastError
                            additionalProperties: false
                            nullable: true
                            description: >-
                              What the last sign-in or token import got. Null
                              while the variable is not connected.
                        required:
                          - status
                          - serverUrl
                          - issuer
                          - authorizationEndpoint
                          - tokenEndpoint
                          - clientId
                          - registration
                          - tokenEndpointAuthMethod
                          - scopes
                          - resource
                          - clientName
                          - redirectUri
                          - connection
                        additionalProperties: false
                        nullable: true
                        description: >-
                          The variable's OAuth provider and connection. Null for
                          a text variable. Tokens are never returned.
                      usedByServices:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: The ID of a service that uses this variable.
                            name:
                              type: string
                              description: The name of the service.
                            type:
                              type: string
                              enum:
                                - http
                                - mcp
                                - postgres
                                - mysql
                                - ssh
                              description: >-
                                The service's type: `http`, `mcp`, `postgres`,
                                `mysql` or `ssh`.
                            hostPattern:
                              type: string
                              nullable: true
                              description: >-
                                The host pattern of the service. Null for a
                                `postgres`, `mysql` or `ssh` service.
                            accessBundles:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: The ID of the access bundle.
                                  name:
                                    type: string
                                    description: The name of the access bundle.
                                required:
                                  - id
                                  - name
                                additionalProperties: false
                              description: >-
                                The access bundles the service is in. A member
                                sees only the ones they have been granted.
                          required:
                            - id
                            - name
                            - type
                            - hostPattern
                            - accessBundles
                          additionalProperties: false
                        description: >-
                          The services that use this variable, across every
                          access bundle, ordered by access bundle name and then
                          service name. For a personal variable, the services
                          whose personal values, as you set them, use it. A
                          variable in use can't be deleted.
                      createdAt:
                        type: string
                        format: date-time
                        description: When the variable was added.
                      updatedAt:
                        type: string
                        format: date-time
                        description: When the variable was last changed.
                    required:
                      - id
                      - key
                      - scope
                      - type
                      - oauth
                      - usedByServices
                      - createdAt
                      - updatedAt
                    additionalProperties: false
                required:
                  - variable
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 400
                  message:
                    type: string
                  error:
                    type: string
                  details: {}
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 401
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 403
                  message:
                    type: string
                  details: {}
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 404
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '422':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 422
                  message: {}
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - error
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 500
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.