TsgcHTTP_OAuth2_ServerMethods › RemoveToken

RemoveToken Method

Revokes a specific access token previously issued by the server.

Syntax

function RemoveToken(const aToken: string): Boolean;

Parameters

NameTypeDescription
aTokenconst stringThe access token string to invalidate. It must match a token currently held in the server store.

Return Value

Returns True when the token is found and removed from the store; False when no matching token exists. (Boolean)

Remarks

After the token is removed, any subsequent request presenting it fails the IsOAuth2TokenValid check and the client is treated as unauthorized. Use RemoveTokenByRefreshToken when you only know the refresh token.

Example

// Forcibly revoke an access token (for example, after a logout)
if OAuth2.RemoveToken('abc123accesstoken') then
  WriteLn('Token revoked');

Back to Methods