I am assuming HTTPRequest.User and HTTPRequest.Password are for basic authentication and have tried setting them but it seems they are ignored.

I can add a header for Basic Authentication manually and it works fine.

So how can I base64 encode the credentials to add into the header?
I cannot find a function to use.

You can use TWebHTTPRequest.Headers to add header info and you can use the function atob() in web.pas to perform base64 encoding.

This maps on:

Please, give an example Basic and JWT Authentication for TWebHttpRequest

Please, give an example Basic Authentication for TWebHttpRequest

This all depends on the exact authentication flow your server expects.

In TMS XData for example, it is JWT based and we have support built-in in the components and info about it can be found here:

If this is with another server and perhaps a different authentication flow, a starting point can be found here using basic HTTP that you could implement using the TWebHttpRequest in Pascal