# Get Authorization Code

This is the first step of the OAuth2 process. An authorization code is created when the user authorizes your application to access their account. If the user grants permission to your application, the callback URL registered in your application will be invoked. The interface for obtaining the authorization code is completed in the browser.<br/> <b>'SEND API REQUEST' function for this endpoint does not work in UAT environment</b>.

# OpenAPI definition

```json
{
  "info": {
    "title": "Webull Open API Reference",
    "description": "application.yml\\ncom\\ni18n\\nMETA-INF\\nstatic\\n\\r\\n",
    "contact": {
      "name": "",
      "url": "",
      "email": ""
    },
    "version": "2.0",
    "x-logo": {
      "url": "static/png/logo.png"
    }
  },
  "servers": [
    {
      "url": "https://oauth-open-api.sandbox.webull.com"
    }
  ],
  "path": "/oauth2/auth-codes/get",
  "method": "get",
  "tags": [
    "Connect"
  ],
  "description": "This is the first step of the OAuth2 process. An authorization code is created when the user authorizes your application to access their account. If the user grants permission to your application, the callback URL registered in your application will be invoked. The interface for obtaining the authorization code is completed in the browser.<br/> <b>'SEND API REQUEST' function for this endpoint does not work in UAT environment</b>.",
  "operationId": "getAuthorizationCode",
  "parameters": [
    {
      "name": "response_type",
      "in": "query",
      "description": "Must be code to request an authorization code.",
      "required": true,
      "schema": {
        "type": "String"
      },
      "example": "code"
    },
    {
      "name": "client_id",
      "in": "query",
      "description": "Webull provides the client id",
      "required": true,
      "schema": {
        "type": "String"
      },
      "example": "CLINETTEST"
    },
    {
      "name": "scope",
      "in": "query",
      "description": "The application requests access to the list of scopes. user：user trade：trade wr：write read.",
      "required": true,
      "schema": {
        "type": "String"
      },
      "example": "user:trade:wr"
    },
    {
      "name": "state",
      "in": "query",
      "description": "An unguessable random string, used to protect against request forgery attacks.",
      "required": true,
      "schema": {
        "type": "String"
      },
      "example": "MiLCJjb25uZWN0aW9uX3R5cGUiOiJs"
    },
    {
      "name": "redirect_uri",
      "in": "query",
      "description": "The URL to which the user will be redirected after authorization. It must match the redirect URIs in whitelist.",
      "required": true,
      "schema": {
        "type": "String"
      },
      "example": "http://callbackurl.com"
    }
  ],
  "responses": {
    "302": {
      "description": "After successful authorization, it will call back to the redirect_uri in the request parameters, structured as follows:<br/> http://testcallbackurl.com?code=NjVhODIxODItYTAzMC00Y2IxLTkzNzQt&state=MiLCJjb25uZWN0aW9uX3R5cGUiOiJs"
    },
    "401": {
      "description": "Unauthorized: Authentication required",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error_code": {
                "type": "string",
                "description": "Internal logic error code",
                "example": "UNAUTHORIZED"
              },
              "message": {
                "type": "string",
                "description": "Error message",
                "example": "Insufficient permission"
              }
            }
          }
        }
      }
    },
    "417": {
      "description": "A business logic error triggered when the request cannot be processed due to domain-specific constraints.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error_code": {
                "type": "string",
                "description": "Internal logic error code",
                "example": "INVALID_PARAMETER"
              },
              "message": {
                "type": "string",
                "description": "Error message",
                "example": "Parameter error, phone"
              }
            }
          }
        }
      }
    },
    "500": {
      "description": "Internal Server Error.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error_code": {
                "type": "string",
                "description": "Internal logic error code",
                "example": "SYSTEM_ERROR"
              },
              "message": {
                "type": "string",
                "description": "Error message",
                "example": "Internal Server Error"
              }
            }
          }
        }
      }
    }
  },
  "postman": {
    "name": "Get Authorization Code",
    "description": {
      "content": "This is the first step of the OAuth2 process. An authorization code is created when the user authorizes your application to access their account. If the user grants permission to your application, the callback URL registered in your application will be invoked. The interface for obtaining the authorization code is completed in the browser.<br/> <b>'SEND API REQUEST' function for this endpoint does not work in UAT environment</b>.",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "oauth2",
        "auth-codes",
        "get"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) Must be code to request an authorization code.",
            "type": "text/plain"
          },
          "key": "response_type",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) Webull provides the client id",
            "type": "text/plain"
          },
          "key": "client_id",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) The application requests access to the list of scopes. user：user trade：trade wr：write read.",
            "type": "text/plain"
          },
          "key": "scope",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) An unguessable random string, used to protect against request forgery attacks.",
            "type": "text/plain"
          },
          "key": "state",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) The URL to which the user will be redirected after authorization. It must match the redirect URIs in whitelist.",
            "type": "text/plain"
          },
          "key": "redirect_uri",
          "value": ""
        }
      ],
      "variable": []
    },
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "GET"
  }
}
```
