User Profile
These functions read and update user profile data from the OIDC userinfo endpoint and the SCIM2 /Me endpoint.
getUserInfo(config)
Fetch user claims from the OIDC userinfo endpoint. Requires a valid access token attached to the request.
import { getUserInfo } from '@thunderid/javascript'
const user = await getUserInfo({
url: 'https://localhost:8090/oauth2/userinfo',
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
console.log(user.email, user.displayName)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
config.url | string | ✅ | Full userinfo endpoint URL |
config.headers | Record<string, string> | — | Request headers. Include Authorization: Bearer <token> |
Response: User
| Property | Type | Description |
|---|---|---|
sub | string | Subject identifier (unique user ID) |
displayName | string | User's display name |
username | string | Username |
email | string | Email address |
given_name | string | First name |
family_name | string | Last name |
picture | string | Profile picture URL |
Additional claims returned by the server are accessible as user[claimUri].
getScim2Me(config)
Fetch the authenticated user's full profile from the SCIM2 /Me endpoint. Returns more attributes than getUserInfo() (custom claims, enterprise attributes, etc.).
import { getScim2Me } from '@thunderid/javascript'
const user = await getScim2Me({
baseUrl: 'https://localhost:8090',
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
config.url | string | ✅ | Full SCIM2 /Me endpoint URL. Mutually exclusive with baseUrl |
config.baseUrl | string | ✅ | ThunderID base URL. SDK appends /scim2/Me |
config.fetcher | function | — | Custom fetch function override |
config.headers | Record<string, string> | — | Additional request headers |
Response: User
Returns the same User type as getUserInfo(), but may include additional SCIM2 attributes.
updateMeProfile(config)
Update the authenticated user's profile via the SCIM2 /Me PATCH endpoint.
import { updateMeProfile } from '@thunderid/javascript'
const updated = await updateMeProfile({
baseUrl: 'https://localhost:8090',
payload: {
Operations: [
{
op: 'replace',
value: {
name: {
givenName: 'Updated',
familyName: 'Name',
},
},
},
],
schemas: ['urn:ietf:params:scim:api:messages:2.0:PatchOp'],
},
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
config.url | string | ✅ | Full SCIM2 /Me endpoint URL. Mutually exclusive with baseUrl |
config.baseUrl | string | ✅ | ThunderID base URL |
config.payload | object | ✅ | SCIM2 PatchOp request body |
config.payload.Operations | object[] | ✅ | Array of PATCH operations (op, value, path) |
config.payload.schemas | string[] | ✅ | Must include 'urn:ietf:params:scim:api:messages:2.0:PatchOp' |
config.fetcher | function | — | Custom fetch function override |
Response: User
The updated user profile.