MODULE 10 · LESSON 10.4
Build user consent into your client
Own interactive consent in the client application.
Lesson 56 of 86 · FabrCore 2.0
Overview
The broker exposes begin/complete/status operations, but the client opens the browser and handles the callback. PKCE, nonce, single-use state and exact callbacks bind the result to the initiating flow. An administrator's permission to edit a profile is not the user's consent.
The external client owns the browser interaction
Begin returns information the client uses to open the provider's authorization page. The client handles the configured callback and completes the broker flow. PKCE, nonce and one-time state bind that response to the original initiation. The Cloud Server may help manage profiles or encrypted relays, but it is not the browser session in which the user grants consent.
State must belong to the initiating user
Store the pending flow with its intended owner and expiry. Handle cancellation and provider errors explicitly so the UI does not display Connected before completion succeeds. Reusing a callback from a different flow or account should fail. Tokens and authorization codes belong in protected flow handling, not ordinary agent messages, cloud logs or queryable work records.
Complete the user's consent flow
- Call the connections client to begin authorization, navigate to the returned provider URL and retain the client-side flow context.
- Complete the callback through the supported API with the exact registered URI. Validate state and user proof; never forward codes or tokens into agent prompts.
- Display status, retry/cancel and disconnect. Handle reauthorization when a profile revision changes and reset local account-specific UI appropriately.
// http authenticates the current user to FabrCore, not to Graph or Google.
var connections = new FabrCoreConnectionsClient(http);
var transaction = await connections.BeginAsync(
new("work", "https://my-client.example/connections/callback"));
// Client navigates the browser to transaction.AuthorizationUrl.
// Remember transaction.State and connection name in the client's session.
// On the registered callback, verify returned state against that client session.
await connections.CompleteAsync(new(
"work", returnedState, returnedCode, returnedProviderError));
Exercise consent, cancellation and replay
- Begin the flow for a test user and the requested resource. Complete sign-in/consent through the actual callback and inspect the broker's status before showing Connected.
- Cancel a second flow. The client should show cancellation or disconnected status and offer a fresh start; it should not treat visiting the consent page as completion.
- Replay a consumed callback or complete it under the wrong account in a controlled test. Expect rejection with no newly authorized grant.
The meaningful result is a valid, owner-bound completed grant. A login page opening or an administrator saving a profile is not user consent.
If the result is different
Keep code/token values out of logs and ordinary cloud commands. A timeout is not permission to reuse a single-use authorization result.
Go deeper
Explore the related documentation.