Skip to main content
GET
/
users
/
me
Get Current User Info
curl --request GET \
  --url https://api.example.com/users/me \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "password": "<string>"
}
'
{
  "id": 123,
  "username": "<string>",
  "email": "<string>",
  "password": "<string>",
  "role": "<string>"
}

Overview

Retrieves the current authenticated user’s information by validating their email and password credentials.

Authentication

This endpoint requires:
  • A valid JWT token in the Authorization header
  • The user must have ROLE_USER authority
  • Valid email and password in the request body

Request

Headers

Authorization: Bearer <jwt_token>
Content-Type: application/json

Body Parameters

email
string
required
The email address of the user
password
string
required
The user’s password

Response

id
long
The unique identifier of the user
username
string
The username of the user
email
string
The email address of the user
password
string
The encrypted password of the user
role
string
The role assigned to the user (e.g., ROLE_USER, ROLE_ADMIN)

Example Request

curl -X GET http://localhost:8080/users/me \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "NorUs1234"
  }'

Example Response

{
  "id": 2,
  "username": "normal-user",
  "email": "[email protected]",
  "password": "$2a$10$zAjODzgBZhCuL80b1OT51.jpYuOB8WmwqZ/u9ls4Xf7r0.7Vh9.jy",
  "role": "ROLE_USER"
}

Error Responses

400 Bad Request

Returned when the request body validation fails.
{
  "message": "Error de validacion",
  "statusCode": 400,
  "errors": [
    "Email is required",
    "Password is required"
  ]
}

401 Unauthorized

Returned when:
  • No JWT token is provided
  • The JWT token is invalid or expired
  • The credentials (email/password) are incorrect
{
  "error": "Unauthorized",
  "message": "Authentication failed"
}

403 Forbidden

Returned when the user does not have the required ROLE_USER authority.
{
  "error": "Forbidden",
  "message": "Access denied"
}

How to Get a JWT Token

Before calling this endpoint, you need to authenticate and obtain a JWT token:
curl -X POST http://localhost:8080/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "NorUs1234"
  }'
The login response will include a token field that you can use in the Authorization header.

Build docs developers (and LLMs) love