Overview
The InvestGo platform uses JSON Web Tokens (JWT) for authentication. Users must first obtain a token by providing valid credentials, then include this token in theAuthorization header for subsequent API requests.
JWT tokens are valid for 10 hours from the time of generation. After expiration, users must re-authenticate to obtain a new token.
Generate Token
POST /generate-token
Authenticates a user and generates a JWT token for API access.
Request Body
The user’s unique username
The user’s password
Response
The JWT token to be used for authenticated requests. Include this token in the
Authorization header as Bearer {token} for subsequent API calls.Example Request
cURL
Request Body
Example Response
200 - Success
Error Responses
500 - User Not Found
500 - Disabled User
500 - Invalid Credentials
Get Current User
GET /actual-usuario
Retrieves the complete profile information for the currently authenticated user.
Authentication
Bearer token obtained from the
/generate-token endpoint.Format: Bearer {token}Response
Unique identifier for the user
User’s first name
User’s paternal last name
User’s maternal last name
User’s phone number
User’s email address
User’s unique username
Encrypted password (hashed)
URL or path to user’s profile photo
User’s registration or birth date in
yyyy-MM-dd format (America/Lima timezone)User’s national identification number (DNI)
User account status
User role type identifier
User’s role information
List of granted authorities for the user based on their role
Indicates if the account is not expired (always
true)Indicates if the account is not locked (always
true)Indicates if the credentials are not expired (always
true)Indicates if the account is enabled (always
true)Example Request
cURL
Example Response
200 - Success
Error Responses
401 - Unauthorized
403 - Forbidden (Invalid or Expired Token)
The password field in the response is encrypted and cannot be used to authenticate. This is the BCrypt hashed version stored in the database.
Authentication Flow
- Obtain Token: Call
POST /generate-tokenwith username and password - Store Token: Save the returned JWT token securely on the client side
- Use Token: Include the token in the
Authorizationheader for all subsequent requests - Refresh: Generate a new token before the 10-hour expiration period
Token Usage Example
Once you have obtained a token, include it in your API requests:Security Considerations
- Tokens are signed using HS512 algorithm
- Token expiration is set to 10 hours (36,000,000 milliseconds)
- All authentication endpoints support CORS for cross-origin requests
- Failed authentication attempts will throw descriptive exceptions
- User accounts can be disabled to prevent access even with valid credentials