TsgcHTTP_OAuth2_Server › Methods › RegisterApp
Registers a new OAuth 2.0 client application on the server and returns its generated credentials.
function RegisterApp(const aName, aRedirectURI: String; var ClientId, ClientSecret: string): Boolean;
| Name | Type | Description |
|---|---|---|
aName | const String | Logical name of the application (for example, 'MyApp'). Must be unique on the server and is used to correlate tokens with the app. |
aRedirectURI | const String | Redirect URI registered for the authorization code flow (for example, http://127.0.0.1:8080). Incoming authorization requests must supply a matching redirect_uri. |
ClientId | var string | Output parameter that receives the generated client identifier. This value is public and is used by the client to identify itself. |
ClientSecret | var string | Output parameter that receives the generated client secret. Must be kept confidential and shared only with the client application. |
Returns True when the application is registered and the credentials are filled in; False when a duplicate aName already exists. (Boolean)
Use RegisterApp during server configuration to declare every client application that is allowed to obtain tokens. By default the registered application accepts all grant types (authorization code, client credentials, password, device code) and a 1-hour access-token lifetime; those defaults can be adjusted through the Apps collection. Call UnRegisterApp to remove it.
var
vClientId, vClientSecret: string;
begin
if OAuth2.RegisterApp('MyApp', 'http://127.0.0.1:8080',
vClientId, vClientSecret) then
WriteLn(Format('Client registered: %s / %s', [vClientId, vClientSecret]));
end;