TsgcHTTP_OAuth2_ClientMethods › Start

Start Method

Starts the configured OAuth2 flow to obtain an access token.

Syntax

procedure Start;

Remarks

Kicks off the grant type selected in AuthenticationType. For auth2Code it spins up the internal redirect server and opens the user's default browser to the authorization URL; for auth2DeviceCode it requests a device/user code pair and starts polling the token endpoint; for auth2Password and auth2ClientCredentials it posts credentials directly to the token endpoint. Make sure AuthorizationServerOptions (AuthorizationURL, AccessTokenURL, ClientId, ClientSecret, Scope) are configured before calling.

Example

oAuth2.AuthenticationType := auth2Code;
oAuth2.AuthorizationServerOptions.AuthorizationURL := 'https://accounts.google.com/o/oauth2/auth';
oAuth2.AuthorizationServerOptions.AccessTokenURL := 'https://accounts.google.com/o/oauth2/token';
oAuth2.AuthorizationServerOptions.ClientId := 'your-client-id';
oAuth2.AuthorizationServerOptions.ClientSecret := 'your-client-secret';
oAuth2.AuthorizationServerOptions.Scope := 'https://www.googleapis.com/auth/gmail.readonly';
oAuth2.Start;

Back to Methods