Skip to main content

TdxOAuth2AuthorizationAgent.TReceiveAuthorizationCodeEvent Type

The OAuth 2.0 authorization code acquisition event type.

Declaration

TReceiveAuthorizationCodeEvent = procedure(Sender: TObject; out AAuthorizationCode: string) of object;

Parameters

Name Type Description
Sender TObject

The OAuth 2.0-compatible authorization agent that raised an authorization code acquisition event.

AAuthorizationCode string

The received authorization code.

Remarks

An authorization code is a short-lived token that signifies an end user’s consent to grant the data access permissions that the authorization agent requests. Then, the agent uses the authorization code to obtain both the access and refresh tokens from an OAuth 2.0 authorization server.

The authorization code acquisition event occurs immediately after the accesss token acquisition event, which allows you to implement the custom sign-in routine that authenticates the authorization agent in an online account and requests the user consent to grant all necessary permissions.

The Sender parameter provides access to the OAuth 2.0-compatible authorization agent component that raised the event. To access the authorization agent’s class members, cast the parameter value to the corresponding TdxOAuth2AuthorizationAgent class descendant (TdxMicrosoftGraphAPIOAuth2AuthorizationAgent, for instance). You can call the Sender.ClassName function to identify the actual type of the authorization agent component.

Use the AAuthorizationCode parameter to pass the authorization code obtained within the event handler, to the authorization agent. The agent executes the standard authentication routine if an empty string is assigned to the AAuthorizationCode parameter.

The OnReceiveAuthorizationCode event references the TReceiveAuthorizationCodeEvent nested procedural type.

See Also