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

# OAuth2 Authorize

> Initiates the OAuth2 authorization flow with user credentials. This endpoint starts the OAuth2 authorization code flow. The user provides their credentials along with the OAuth2 client details. If MFA is enabled for the user, the response will indicate that MFA is required and provide a next_step_auth_id to be used in the MFA verification step. Supports PKCE (Proof Key for Code Exchange) for enhanced security.



## OpenAPI

````yaml https://spec.speakeasy.com/aries/aries/aries-trading-platform-api-with-code-samples post /v1/oauth2/authorize
openapi: 3.0.3
info:
  title: Aries Trading Platform API
  description: >-
    Complete API documentation for the Aries trading platform including user
    management, authentication, account management, order management, market
    data, and analytics
  contact:
    name: Aries Financial
    email: dev@aries.com
  version: 1.0.0
servers:
  - url: https://api.tradearies.dev
    description: Production server
security: []
tags:
  - name: Accounts
    description: Account management endpoints for positions, orders, and balances
  - name: Analytics
    description: >-
      Analytics endpoints for market data analysis including top gainers,
      losers, volume leaders, sector analysis, analyst ratings, market breadth,
      and net inflow
  - name: Authentication
    description: User authentication endpoints
  - name: Calendars
    description: Calendar endpoints for economic events and historical data
  - name: Market Data
    description: >-
      Market data endpoints for symbol search, real-time data access, and equity
      details
  - name: Orders
    description: >-
      Order management endpoints for placing, updating, canceling, and
      previewing orders
  - name: Users
    description: User management endpoints
  - name: Health
    description: Service health endpoints
paths:
  /v1/oauth2/authorize:
    post:
      tags:
        - OAuth2
      summary: OAuth2 Authorize
      description: >-
        Initiates the OAuth2 authorization flow with user credentials. This
        endpoint starts the OAuth2 authorization code flow. The user provides
        their credentials along with the OAuth2 client details. If MFA is
        enabled for the user, the response will indicate that MFA is required
        and provide a next_step_auth_id to be used in the MFA verification step.
        Supports PKCE (Proof Key for Code Exchange) for enhanced security.
      operationId: oauth2_Authorize
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  description: User's email address
                  example: user@example.com
                password:
                  type: string
                  format: password
                  description: User's password
                  example: SecurePassword123!
                client_id:
                  type: string
                  description: OAuth2 client identifier
                  example: client_abc123xyz
                redirect_uri:
                  type: string
                  format: uri
                  description: Redirect URI registered with the client
                  example: https://yourapp.com/callback
                response_type:
                  type: string
                  description: OAuth2 response type
                  default: code
                  example: code
                scope:
                  type: string
                  description: Space-separated list of requested scopes
                  example: read write
                state:
                  type: string
                  description: >-
                    Opaque value to maintain state between request and callback
                    (CSRF protection)
                  example: random_state_string_123
                code_challenge:
                  type: string
                  description: PKCE code challenge (base64url encoded)
                  example: E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
                code_challenge_method:
                  type: string
                  enum:
                    - S256
                    - plain
                  description: PKCE challenge method
                  example: S256
                sid:
                  type: string
                  description: Session ID for RSA encryption
                  example: session_xyz789
              required:
                - email
                - password
                - client_id
                - redirect_uri
            examples:
              basic:
                summary: Basic OAuth2 authorization
                value:
                  email: user@example.com
                  password: SecurePassword123!
                  client_id: client_abc123xyz
                  redirect_uri: https://yourapp.com/callback
                  response_type: code
                  scope: read write
                  state: random_state_string_123
              pkce:
                summary: OAuth2 with PKCE (for public clients)
                value:
                  email: user@example.com
                  password: SecurePassword123!
                  client_id: client_abc123xyz
                  redirect_uri: https://yourapp.com/callback
                  response_type: code
                  scope: read write
                  state: random_state_string_123
                  code_challenge: E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
                  code_challenge_method: S256
        required: true
      responses:
        '200':
          description: Authorization initiated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  next_step_auth_id:
                    type: string
                    description: Authorization session ID for next step
                  is_mfa:
                    type: boolean
                    description: Whether MFA is required
                  consent_required:
                    type: boolean
                    description: Whether user consent is required
                  client_name:
                    type: string
                    description: Name of the OAuth2 client
                  scopes:
                    type: array
                    items:
                      type: string
                    description: List of requested scopes
              examples:
                mfa_required:
                  summary: MFA is required
                  value:
                    next_step_auth_id: auth_mfa_123abc
                    is_mfa: true
                    client_name: My Application
                    scopes:
                      - read
                      - write
                consent_required:
                  summary: User consent is required
                  value:
                    next_step_auth_id: auth_consent_456def
                    consent_required: true
                    client_name: My Application
                    scopes:
                      - read
                      - write
                ready_to_confirm:
                  summary: Ready to confirm authorization
                  value:
                    next_step_auth_id: auth_confirm_789ghi
                    client_name: My Application
                    scopes:
                      - read
                      - write
        '400':
          description: Bad request - invalid parameters or client credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - invalid user credentials
        '500':
          description: Internal server error
      x-codeSamples:
        - lang: java
          label: Java (SDK)
          source: >-
            package hello.world;


            import java.lang.Exception;

            import org.openapis.openapi.AriesJava;

            import org.openapis.openapi.models.errors.ErrorResponse;

            import
            org.openapis.openapi.models.operations.Oauth2AuthorizeRequest;

            import
            org.openapis.openapi.models.operations.Oauth2AuthorizeResponse;


            public class Application {

                public static void main(String[] args) throws ErrorResponse, Exception {

                    AriesJava sdk = AriesJava.builder()
                            .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
                        .build();

                    Oauth2AuthorizeRequest req = Oauth2AuthorizeRequest.builder()
                            .email("user@example.com")
                            .password("SecurePassword123!")
                            .clientId("client_abc123xyz")
                            .redirectUri("https://yourapp.com/callback")
                            .scope("read write")
                            .state("random_state_string_123")
                            .build();

                    Oauth2AuthorizeResponse res = sdk.oAuth2().authorize()
                            .request(req)
                            .call();

                    if (res.object().isPresent()) {
                        // handle response
                    }
                }
            }
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message
        codes:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                description: Error code
              description:
                type: string
                description: Error description

````