TsgcHTTP_JWT_ClientMethods › Start

Start Method

Signs the configured JWT and delivers it as a Bearer token to the host HTTP / WebSocket client.

Syntax

procedure Start;

Remarks

Internally calls Sign to build and sign the token from JWTOptions, then hands the result to the parent auth-token infrastructure so it is attached as Authorization: Bearer <jwt> on the next request of the HTTP/2, HTTP/1 or WebSocket client the component is linked to. When signing fails or the resulting token is empty the internal error event is raised instead. Use Start when the JWT client is wired to a host client via Authentication.Token.JWT; call Sign directly if you only need the encoded string.

Example


oHTTP := TsgcHTTP2Client.Create(nil);

oJWT := TsgcHTTP_JWT_Client.Create(nil);
oJWT.JWTOptions.Header.alg := jwtRS256;
oJWT.JWTOptions.Algorithms.RS.PrivateKey.Text := vPrivateKeyPEM;
oJWT.JWTOptions.Payload.iss := '2886EC7547B7BA6A9009';
oJWT.JWTOptions.Payload.sub := '1234567890';
oJWT.JWTOptions.RefreshTokenAfter := 60 * 40;

oHTTP.Authentication.Token.JWT := oJWT;
oJWT.Start;
oHTTP.Get('https://your.api.com');

Back to Methods