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

# Auth Token

> Obtain OAuth 2.0 access token. This endpoint follows the OAuth 2.0 industry-standard protocol for authorization.
It performs authorization and returns the access token and refresh token.

To use, pass the `grant_type` in the form data, which will be:
- `client_credentials` grant type to authenticate with `client_id` and `client_secret`.
- `refresh_token` grant type to refresh an existing token.

If using `client_credentials` grant type, please use HTTP Basic Auth to pass the credentials
(with the username being the `client_id` and the password being the `client_secret`).

The `client_id` and `client_secret` can be passed in the form data, but this is deprecated and
not recommended.


Possible Codes in Error Response (see [Errors](https://docs.volteras.com/api-reference/errors) for error response schema and meaning of codes):

- AUTHENTICATION_ERROR
- REQUEST_VALIDATION_ERROR
- SERVER_ERROR



## OpenAPI

````yaml post /v1/oauth2/token
openapi: 3.1.0
info:
  title: VOLTERAS CONNECT
  version: 0.1.0
servers:
  - url: https://api.volteras.com
  - url: https://api.sandbox.volteras.com
security: []
paths:
  /v1/oauth2/token:
    post:
      tags:
        - Authentication
      summary: Auth Token
      description: >-
        Obtain OAuth 2.0 access token. This endpoint follows the OAuth 2.0
        industry-standard protocol for authorization.

        It performs authorization and returns the access token and refresh
        token.


        To use, pass the `grant_type` in the form data, which will be:

        - `client_credentials` grant type to authenticate with `client_id` and
        `client_secret`.

        - `refresh_token` grant type to refresh an existing token.


        If using `client_credentials` grant type, please use HTTP Basic Auth to
        pass the credentials

        (with the username being the `client_id` and the password being the
        `client_secret`).


        The `client_id` and `client_secret` can be passed in the form data, but
        this is deprecated and

        not recommended.



        Possible Codes in Error Response (see
        [Errors](https://docs.volteras.com/api-reference/errors) for error
        response schema and meaning of codes):


        - AUTHENTICATION_ERROR

        - REQUEST_VALIDATION_ERROR

        - SERVER_ERROR
      operationId: auth_token_v1_oauth2_token_post
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Body_auth_token_v1_oauth2_token_post'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIAccessToken'
      security:
        - HTTPBasic: []
components:
  schemas:
    Body_auth_token_v1_oauth2_token_post:
      properties:
        client_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Client Id
          description: Your client ID.
        client_secret:
          anyOf:
            - type: string
            - type: 'null'
          title: Client Secret
          description: Your client secret.
        refresh_token:
          anyOf:
            - type: string
            - type: 'null'
          title: Refresh Token
          description: >-
            The refresh token acquired during authentication with the
            `client_credentials` `grant_type`.
        grant_type:
          type: string
          title: Grant Type
          description: OAuth 2.0 grant type.
      type: object
      title: Body_auth_token_v1_oauth2_token_post
    APIAccessToken:
      properties:
        access_token:
          type: string
          title: Access token
          description: The access token used for authenticated requests.
        token_type:
          type: string
          title: Token type
          description: Type of the token.
        expires_in:
          type: integer
          title: Expires in
          description: Integer with the seconds that the access token will be expired in.
        refresh_token:
          type: string
          title: Refresh token
          description: >-
            The token used to refresh the authentication and retrieve a new
            access token.
      type: object
      required:
        - access_token
        - token_type
        - expires_in
        - refresh_token
      title: APIAccessToken
      description: >-
        Schema of the APIAccessToken, returned by the authentication or refresh
        token
  securitySchemes:
    HTTPBasic:
      type: http
      scheme: basic

````