Custom sign-in
Before you start
Section titled “Before you start”An https endpoint of your own, on port 443, that answers who the client is. The platform calls
it with the payload the game sent, signed with a secret, and reads the identity from the answer.
In the Dashboard
Section titled “In the Dashboard”Choose an environment in the header, open Project settings → Authentication and add a Custom sign-in connection.
| Field | Meaning |
|---|---|
Url | An https address on port 443 without user info, such as https://auth.example.com/rudder. |
Secret | Enter your secret, or leave it empty for Rudder to generate one. It is shown once after saving. |
In the game
Section titled “In the game”The game sends the object you and your server agreed on.
TypeScript
Section titled “TypeScript”import { Session } from '@rudder/sdk';
const session = await Session.signIn(key, { provider: 'web-login', payload: { token },});C# and Unity
Section titled “C# and Unity”using RudderSdk;
var session = await Session.SignInAsync(key, new ProviderSignIn{ Provider = "web-login", Payload = new Dictionary<string, object?> { ["token"] = token },});web-login here is the name you gave the connection, not a provider kind.
The request
Section titled “The request”The platform posts the payload to your URL:
POST https://auth.example.com/rudderContent-Type: application/jsonX-Rudder-Timestamp: 1761744000X-Signature: 2196d2aa9a9a873ce1fa833820701ba041c08780a2e4af11b03cd6e224c91e08
{"customData":{"token":"abc"}}customDatais exactly the payload of the client: a JSON object of at most 16 KB and at most 32 keys. The platform does not look inside it.X-Rudder-Timestampis the Unix time in seconds.X-Signatureis the hex HMAC-SHA256 of<timestamp>.<body>with the provider secret, where<body>is the exact bytes of the request body.
The call waits three seconds and is not retried. At most 32 are in flight at once.
Verify the signature
Section titled “Verify the signature”- Read the raw body bytes — before any JSON parser touches them.
- Take
X-Rudder-Timestampand the provider secret. - Compute
HMAC-SHA256(secret, timestamp + "." + body)and compare it withX-Signaturein constant time. - Reject the request when the signature does not match, or the timestamp is more than 5 minutes away from your clock.
Only then trust customData.
Answer
Section titled “Answer”{"subject": "account-42", "nickname": "Ada", "avatarUrl": "https://cdn.example.com/ada.png"}subject is required, 1–256 bytes, and unique among the accounts of this provider: a changed
subject signs the player in as a new one. nickname (at most 32 characters) and avatarUrl
(an http or https address) fill what the player does not have yet.
Errors
Section titled “Errors”200with the JSON above signs the player in.- Any other
4xxanswers the client401 unauthorized. - Anything else — another status, a timeout, a body that is not JSON, a missing subject or a
bad avatar — answers
503 try_again.
The rest are in Errors.