Skip to main content

Get User Info (Game Client)

Retrieve the authenticated user's profile, roles, and organizations from a game client.

Endpoint

GET /api/v2/user/game

Authentication

This endpoint requires both the game client key and the user's JWT token (with scope: "game"):

x-game-key: your-game-client-key
Authorization: Bearer user-jwt-token

The JWT token is the idToken received during the magic login flow.

Request Example

curl -X GET https://api.intraverse.io/api/v2/user/game \
-H "x-game-key: your-game-client-key" \
-H "Authorization: Bearer eyJhbGciOi..."

Response

Success Response (200)

{
"user": {
"id": "user-abc-123",
"username": "cool-panda-42",
"email": "user@example.com",
"referralCode": "ABC123",
"referredBy": "user-xyz-789",
"referrer": "another-player",
"skipReferral": false
},
"roles": [
{
"id": "role-1",
"name": "Player",
"isSuperAdmin": false,
"permissions": [
{
"key": "game.play",
"name": "Play Game",
"description": "Can play the game"
}
]
}
],
"organizations": [
{
"id": "org-1",
"name": "Intraverse",
"isMain": true
}
]
}

Response Fields

FieldTypeDescription
userobjectUser profile
user.idstringUnique user ID
user.usernamestringDisplay name
user.emailstring?Email address (may be absent)
rolesarrayRoles assigned to the user
organizationsarrayOrganizations the user belongs to

Error Responses

CodeMessageDescription
401UnauthorizedMissing or invalid JWT token
401Invalid scopeToken does not have game scope
401Missing client keyx-game-key header not provided
404Game not foundClient key does not match any game
404User not foundUser ID from token not found

Usage Example

const response = await fetch("https://api.intraverse.io/api/v2/user/game", {
method: "GET",
headers: {
"x-game-key": gameClientKey,
Authorization: `Bearer ${idToken}`,
},
});

const { user, roles, organizations } = await response.json();
console.log(`Logged in as: ${user.username}`);

Next Steps