Overview
Theauthorize() method on the Grantex client initiates the delegated authorization flow. It creates an authorization request and returns a consent URL that the user must visit to approve the requested scopes.
Usage
user_id parameter is transparently mapped to principalId in the API request body.
Parameters
AuthorizeParams is a dataclass with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | str | Yes | The ID of the agent requesting authorization. |
user_id | str | Yes | The user (principal) being asked to grant permissions. |
scopes | list[str] | Yes | The permission scopes being requested. |
expires_in | str | None | No | How long the authorization request remains valid (e.g. "1h"). |
redirect_uri | str | None | No | URL to redirect the user after consent. |
code_challenge | str | None | No | PKCE code challenge (S256). See PKCE. |
code_challenge_method | str | None | No | Must be "S256" when using PKCE. |
Response
authorize() returns an AuthorizationRequest frozen dataclass:
| Field | Type | Description |
|---|---|---|
request_id | str | The authorization request ID (authRequestId). |
consent_url | str | URL to redirect the user for consent approval. |
agent_id | str | The agent ID from the request. |
principal_id | str | The user/principal ID. |
scopes | tuple[str, ...] | The requested scopes. |
expires_in | str | The TTL of the authorization request. |
expires_at | str | ISO 8601 timestamp when the request expires. |
status | str | Current status (e.g. "pending"). |
created_at | str | ISO 8601 timestamp when the request was created. |