Overview
Theauthorize() method starts the Grantex authorization flow. It creates an authorization request and returns a consent URL where the user can approve or deny the requested scopes.
The
userId parameter is mapped to principalId in the API request body. This is the identifier for the human user in your system.Parameters
The scopes the agent is requesting. Must be a subset of the agent’s registered scopes.
Intended token recipient. When set, the issued grant token includes this value in its
aud claim; verifiers should require the same audience.How long the grant should last (e.g.
'1h', '24h', '7d'). Defaults to the server-configured maximum.The URL to redirect the user to after they approve or deny the request. The authorization
code will be appended as a query parameter.PKCE S256 code challenge. Use
generatePkce() to create this value. See PKCE.Response
The method returns anAuthorizationRequest object:
Full example
Next steps
After the user approves the request at theconsentUrl, your redirectUri receives an authorization code. Exchange it for a grant token using tokens.exchange().