Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/10/22 in all areas

  1. Hi I've got this example from the forum. You have to set up the application in Azure. UniSession.Log('Got Code - see if we can get an token...'); http:=TNetHTTPClient.Create(Self); params:=Tstringlist.Create; params.Add('code=' + UniMainmodule.AzureAuthCode); params.Add('client_id=' + C_client_id_Az); // params.Add('client_secret=' + UriEncode(C_client_secret_Az)); params.Add('client_secret=' + C_client_secret_Az); params.Add('scope=' + C_scope_Az); params.Add('redirect_uri=' + C_redirect_uri_Az); params.Add('grant_type=authorization_code'); Lresponse:=http.Post('https://login.microsoftonline.com/organizations/oauth2/v2.0/token', params); UniSession.Log(Lresponse.ContentAsString()); if Lresponse.StatusText = 'OK' then begin token:=GetSimpleValue(Lresponse.ContentAsString, 'access_token'); GToken:=stringreplace (token,'"','',[rfreplaceall]);; UniSession.Log(Lresponse.ContentAsString); aMsg:=Lresponse.ContentAsString; //set username UniSession.Log('getuserInfo'); lresponse := http.get ('https://graph.microsoft.com/v1.0/me',nil,[TNetHeader.Create('Authorization','Bearer ' + gtoken)]); if lresponse.StatusText='OK' then begin UniSession.Log(Lresponse.ContentAsString); unimainmodule.AUserName := stringreplace (GetSimpleValue (lresponse.ContentAsString,'mail'),'"','',[rfreplaceall]); unimainmodule.LoginType := 2; end; // Handled:=True; end; Except on E : exception do unimainmodule.logintype := 0; // catch all unwanted exception here ! It worked for me... Regards Leon logindemo.zip
    1 point
×
×
  • Create New...