TdxAuthorizationAgentUserInfo.GetUserInfo(TdxCustomAuthorizationAgent) Method
Creates a new user information provider for the specified authorization agent component.
Declaration
class function GetUserInfo(AAuthorizationAgent: TdxCustomAuthorizationAgent): TdxAuthorizationAgentUserInfo; static;
Parameters
Name | Type | Description |
---|---|---|
AAuthorizationAgent | TdxCustomAuthorizationAgent | The target authorization agent component. This parameter value initializes the AuthorizationAgent property of the created information provider instance if the function call is successful. |
Returns
Type | Description |
---|---|
TdxAuthorizationAgentUserInfo | The created user information provider. You may need to cast the returned object to the corresponding terminal TdxAuthorizationAgentUserInfo class descendant to access all public API members. Note The actual user information provider type depends on the target authorization agent component passed as the The created TdxAuthorizationAgentUserInfo descendant instance is not managed by its parent authorization agent component. You need to call the Free procedure (in Delphi) or use the |
Remarks
Call the GetUserInfo
class function to create a compatible user information provider for the required authorization agent component. The created provider can use the associated authorization agent component to connect to an online account and load user information.
Call the UpdateInfo procedure to connect the user information provider to an online account through the configured parent authorization agent and load user information.
Code Example
The following code example creates a user information provider and uses a configured TdxMicrosoftGraphAPIOAuth2AuthorizationAgent component to display user information from an online account in the form caption:
var
AInfo: TdxAuthorizationAgentUserInfo;
begin
AInfo := TdxAuthorizationAgentUserInfo.GetUserInfo(dxMicrosoftGraphAPIOAuth2AuthorizationAgent1);
if AInfo = nil then Exit;
try
AInfo.UpdateInfo; // Obtains user information through the authorization agent component
Caption := Caption + Format(' User Name: %s; e-mail: %s', [AInfo.DisplayName, AInfo.Mail]);
finally
AInfo.Free; // Releases the user information provider to avoid memory leaks
end;
end;