curl --request GET \
--url https://services.pref.rio/heimdall-admin/api/v1/users/me \
--header 'Authorization: Bearer <token>'import requests
url = "https://services.pref.rio/heimdall-admin/api/v1/users/me"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://services.pref.rio/heimdall-admin/api/v1/users/me', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://services.pref.rio/heimdall-admin/api/v1/users/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://services.pref.rio/heimdall-admin/api/v1/users/me"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://services.pref.rio/heimdall-admin/api/v1/users/me")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://services.pref.rio/heimdall-admin/api/v1/users/me")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": 1,
"cpf": "12345678901",
"display_name": "João Silva",
"groups": [
"engineering_team:backend",
"data_analysts:read"
],
"roles": [
"superadmin",
"data_analyst:read"
]
}{
"detail": "Could not validate credentials"
}{
"detail": "Failed to retrieve user information: Database connection error"
}Get current user information
Retrieve detailed information about the currently authenticated user based on their JWT token.
Authentication: Uses the JWT token to automatically identify the user by their CPF
from the preferred_username field in the Keycloak token.
Auto-Retrieval: No need to specify the CPF - it’s automatically extracted from the JWT token.
Auto-Creation: If the user doesn’t exist in the system, they are automatically created during the authentication process.
Role Aggregation: The response includes both direct roles assigned to the user and roles inherited through group memberships.
Use Cases:
- User profile display in self-service applications
- Current user context for frontend applications
- Session management and user state tracking
- Self-service user information retrieval
- Profile settings and preferences display
Security: Only returns information about the authenticated user - no access to other users’ data.
curl --request GET \
--url https://services.pref.rio/heimdall-admin/api/v1/users/me \
--header 'Authorization: Bearer <token>'import requests
url = "https://services.pref.rio/heimdall-admin/api/v1/users/me"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://services.pref.rio/heimdall-admin/api/v1/users/me', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://services.pref.rio/heimdall-admin/api/v1/users/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://services.pref.rio/heimdall-admin/api/v1/users/me"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://services.pref.rio/heimdall-admin/api/v1/users/me")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://services.pref.rio/heimdall-admin/api/v1/users/me")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": 1,
"cpf": "12345678901",
"display_name": "João Silva",
"groups": [
"engineering_team:backend",
"data_analysts:read"
],
"roles": [
"superadmin",
"data_analyst:read"
]
}{
"detail": "Could not validate credentials"
}{
"detail": "Failed to retrieve user information: Database connection error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Response
Current user information retrieved successfully
Response model for user information.
Unique identifier for the user
1
User's CPF (Cadastro de Pessoa Física) - Brazilian tax ID
^[0-9]{11}$"12345678901"
User's display name from JWT token (name, given_name, or email)
"João Silva"
List of groups the user belongs to
[
"engineering_team:backend",
"data_analysts:read"
]
List of roles assigned to the user (both direct and through groups)
["superadmin", "data-analyst"]
