OAuth2 Provider | Richieste

Una volta completata con successo l'autenticazione, è possibile inviare richieste al server protetto OAuth2 utilizzando il token ID pubblico memorizzato come cookie.

 

Il componente server provider OAuth2 dispone di diversi metodi per inviare richieste HTTP: GET, POST, DELETE...

 

È possibile passare il token come parametro oppure passare la classe RequestInfo se si utilizzano i componenti server Indy.

 


procedure OnCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
  if ARequestInfo.Document = '/private' then
  begin
    // return OAuth2 profile data
    AResponseInfo.ContentText := OAuth2Provider.Get(ARequestInfo, 'https://graph.microsoft.com/v1.0/me');
    AResponseInfo.ContentType := 'application/json';
    AResponseInfo.ResponseNo := 200;
  end
  else
    AResponseInfo.ResponseNo := 404;
end;