Hossein Fallah
Hossein Fallah

Reputation: 2589

How to get first name and last name from Keycloak's REST API?

I use this curl command to get a token:

curl \
  -d "client_id=admin-cli" \
  -d "username=admin" \
  -d "password=admin_password" \
  -d "grant_type=password" \
  "https://example.com/auth/realms/master/protocol/openid-connect/token"

Then I use this curl command to get the list of users for my Development realm:

  curl \
  -H "Authorization: bearer token" \
  "https://example.com/auth/admin/realms/Development/users"

And it returns a list of users. This is the response JSON for a sample user:

{
    "id": "9ca4216f-d13e-49f9-8c35-36e60916c6a9",
    "createdTimestamp": 1631337976997,
    "username": "[email protected]",
    "enabled": true,
    "totp": false,
    "emailVerified": false,
    "email": "[email protected]",
    "disableableCredentialTypes": [],
    "requiredActions": [],
    "notBefore": 0,
    "access": {
        "manageGroupMembership": true,
        "view": true,
        "mapRoles": true,
        "impersonate": true,
        "manage": true
    }
}

Where is the first name and last name? How can I get that data?

Upvotes: 0

Views: 900

Answers (1)

João Machado
João Machado

Reputation: 34

The easiest reason for them to not show is if those attributes don't exist or aren't populated. Can you confirm that you have a first and last name for that user?

Upvotes: 1

Related Questions