Server OAuth2: consentire richieste non autenticate

· Funzionalità

Per impostazione predefinita, quando OAuth2 è abilitato lato server, tutte le richieste HTTP richiedono l'autenticazione tramite Bearer Token.

Se vuoi consentire l'accesso ad alcune URL senza l'uso di un Bearer Token, puoi usare l'evento OnOAuth2BeforeRequest

Qui sotto trovi un esempio di codice che mostra l'uso dell'evento.

procedure OnOAuth2BeforeRequest(Sender: TObject; aConnection: TsgcWSConnection; aHeaders: TStringList; var Cancel: Boolean);
begin
  if DecodeGETFullPath(aHeaders) = '/Public.html' then
    Cancel := True
  else if DecodePOSTFullPath(aHeaders) = '/Form.html' then
    Cancel := True;  
end;