openapi: 3.1.0
x-stoplight:
  id: r34ws1p61284b
info:
  title: Authentication
  version: '1.0'
  summary: Login to Nalanda API
  description: "This is the authentication service of the Nalanda API. It generates a secure access token (JWT) that must be used to authenticate subsequent API requests.\r\n\r\nLogin is performed using the password grant type, requiring the user’s email and password as credentials. Upon successful authentication, the service returns a JSON Web Token (JWT) that authorizes access to the platform.\r\n\r\nAccess to specific endpoints is permission-based; depending on the user's assigned roles and privileges, some API routes may be accessible while others remain restricted."
  termsOfService: ''
  license:
    name: License
    url: https://developers.onceforall.com/
servers:
  - url: https://api.nalandaglobal.com
    description: Prod
paths:
  /remote/auth/login.action:
    post:
      summary: Post login
      operationId: post-login
      responses:
        '200':
          description: User logged in succesfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                    x-stoplight:
                      id: 7y9ifjhpony9g
              examples:
                Access token:
                  value:
                    access_token: >-
                      eyJhbGciOiJIUzUxMiJ9.eyKlc3MiOiJodHRwczovL3d3dy5uFWxhbmRhZ2xvYmFsLmNvbSIsInN1YiI6Ilk4ZHU3MmFDZEhQSDBIaFlIQ0JVNVE9PSIsInN1YnQiOiJwb3J0YWwiLCJleHAiOjE3MTA5NzY5MDUsImp0aSI6InJ1Z0VKSHBva1hidnA4OVVJZWZuY0EiLCJpYXQiOjE3MDgzNDg5MDUsIm5iZiI6MTcwODM0ODc4NSwiZW52IjoiREVTIn0.lV_KMXXDUoHffjoaigyRYf7ATklajVnTKf-X3OFF0Rd874XDqNjvSToOWQPqPeiPlFfT31GTGqKX5kMHLbm6cw
          headers:
            Accept:
              schema:
                type: string
              description: application/vnd.nalanda.api-v1.0+json
        '401':
          description: Unauthorized
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Login'
            examples:
              Login to Nalanda API:
                value:
                  userName: user@nalandaglobal.com
                  password: 1234testpwd
        description: Post the required fields for login to the Nalanda API
      description: >-
        Login request to Nalanda API.


        DEPRECATED: we recommend migrating to the
        [/api/open/token](https://developers.onceforall.com/nalanda-api/reference/authentication/post-token/) endpoint.
      x-stoplight:
        id: qfu03c3n7zdbn
      deprecated: true
      tags:
        - Deprecated Login
    parameters: []
  /api/open/token:
    post:
      summary: Create token
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Token'
              examples:
                Example 1:
                  value:
                    access_token: BQDBKJ5eo5jxbtpWjVOj7ryS84khybFpP_lTqzV7uV-T_m0cTfwvdn5BnBSKPxKgEb11
                    token_type: Bearer
                    expires_in: 3600
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationError'
        '406':
          description: Not Acceptable
          content: {}
        '500':
          description: Internal Server Error
          content: {}
      operationId: post-token
      x-stoplight:
        id: laxh3d8sm5xyn
      parameters:
        - $ref: '#/components/parameters/Accept'
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Token'
            examples:
              Example 1:
                value:
                  grant_type: password
                  username: user@example.com
                  password: 1234TestPwd
      description: "To authenticate with the Nalanda API, you need to obtain a JWT (JSON Web Token) by making a POST request to the authentication endpoint. This request must include the grant_type parameter, which currently only supports the value \"password\".\r\n\r\nOnce the access token is returned in the response, it should be used to authorize all subsequent API calls. To do this, include the token in the Authorization header of your requests, using the following format:\r\n\r\n\r\n`Authorization: Bearer {{access_token}}\r\n`\r\n This token acts as a key, allowing you to securely access the API's protected.\r\n endpoints.\r\n\r\n`expires_in: 3600` The lifetime in seconds of the access token.  For\r\n         example, the value \"3600\" denotes that the access token will\r\n         expire in one hour from the time the response was generated."
    parameters: []
components:
  schemas:
    Login:
      title: Login
      x-stoplight:
        id: 7r2h0is0gk4d5
      type: object
      properties:
        userName:
          type: string
          x-stoplight:
            id: 0fwm1a5pv3myk
        password:
          type: string
          x-stoplight:
            id: 04936pjbs2jqf
      examples:
        - userName: user@email.com
          password: myPassword
    Token:
      type: object
      x-stoplight:
        id: 8af361ff157da
      x-examples:
        Example 1:
          grant_type: password
          username: user@nalandaglobal.com
          password: 1234testpwd
      examples:
        - grant_type: password
          username: user@example.com
          password: 1234TestPwd
          access_token: BQDBKJ5eo5jxbtpWjVOj7ryS84khybFpP_lTqzV7uV-T_m0cTfwvdn5BnBSKPxKgEb11
          token_type: Bearer
          expires_in: 3600
      title: Token
      required:
        - grant_type
        - username
        - password
      properties:
        grant_type:
          type: string
          writeOnly: true
        username:
          type: string
          writeOnly: true
        password:
          type: string
          writeOnly: true
        access_token:
          type: string
          x-stoplight:
            id: c283cvxciy6tf
          readOnly: true
        token_type:
          type: string
          x-stoplight:
            id: 37kprjbrjgbfq
          readOnly: true
        expires_in:
          type: integer
          x-stoplight:
            id: dgx9tllz3sqv6
          readOnly: true
    AuthenticationError:
      type: object
      x-examples:
        Example 1:
          error: invalid_request
          error_description: Campos de la petición no válidos
      description: >
        Error responses are returned with an HTTP 400 status code (unless specified otherwise), with error and
        error_description parameters. 

        The **error** parameter will always be one of the values listed below.


        invalid_request – The request is missing a parameter so the server can’t proceed with the request. This may also
        be returned if the request includes an unsupported parameter.


        invalid_grant – The authorization code (or user’s password for the password grant type) is invalid or expired.
        This is also the error you would return if the redirect URL given in the authorization grant does not match the
        URL provided in this access token request.


        unsupported_grant_type – If a grant type is requested that the authorization server doesn’t recognize, use this
        code. Note that unknown grant types also use this specific error code rather than using the invalid_request
        above.
      examples:
        - error: invalid_request
          error_description: Campos de la petición no válidos
      required:
        - error
        - error_description
      properties:
        error:
          type: string
        error_description:
          type: string
  securitySchemes: {}
  parameters:
    Accept:
      name: Accept
      in: header
      required: true
      schema:
        type: string
      description: application/vnd.nalanda.api-v1.0+json
  responses:
    TokenResponse:
      description: Example response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Token'
          examples:
            Example 1:
              value:
                access_token: BQDBKJ5eo5jxbtpWjVOj7ryS84khybFpP_lTqzV7uV-T_m0cTfwvdn5BnBSKPxKgEb11
                token_type: Bearer
                expires_in: 3600
  requestBodies:
    TokenRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Token'
          examples:
            Example 1:
              value:
                grant_type: password
                username: user@example.com
                password: 1234TestPwd
