vcl-dxauthorizationagents-dot-tdxauthorizationagentuserinfo-dot-getuserinfo-x28-dxauthorizationagents-dot-tdxcustomauthorizationagent-x29.md
Creates a new user information provider for the specified authorization agent component.
class function GetUserInfo(AAuthorizationAgent: TdxCustomAuthorizationAgent): TdxAuthorizationAgentUserInfo; static;
| 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.
|
| 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 AAuthorizationAgent parameter. If the target component has no corresponding user information provider type, the function returns nil (in Delphi) or nullptr (in C++Builder).
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 delete keyword (in C++Builder) to release the user information provider manually as demonstrated in the code example in the Remarks section to avoid memory leaks.
|
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.
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;
TdxAuthorizationAgentUserInfo* AInfo;
AInfo = TdxAuthorizationAgentUserInfo::GetUserInfo(dxMicrosoftGraphAPIOAuth2AuthorizationAgent1);
if(AInfo == nullptr) { return; }
try
{
AInfo->UpdateInfo(); // Obtains user information through the authorization agent component
Caption = Caption + " User Name: ";
Caption = Caption + AInfo->DisplayName;
Caption = Caption + "; e-mail: ";
Caption = Caption + AInfo->Mail;
}
__finally
{
delete AInfo; // Releases the user information provider to avoid memory leaks
}
See Also
TdxAuthorizationAgentUserInfo.DisplayName Property
TdxAuthorizationAgentUserInfo.Mail Property
TdxAuthorizationAgentUserInfo Class