Trying to connect to via java with no user interaction

All the examples and docs seem to be around a login page being displayed to the user and the user filling in the details.

But I want Auth0 to be hidden in the code. So with Java I would use RestTemplate to create a request in and add User details in the Authorization part of the code. But all this does is generate the login form. I could create code that finds the form and fills in the details, but I dont want to add this extra functionality.

There is a way to fudge it
Takes in a username and a password
TokenRequest token = authAPI.login(username, password.toCharArray());

But it does not authenticate the user details it just creates a TokenRequest. You can pass it anything. So i guess the next step is handle the TokenRequest. It seems this functionality is handled by oauth2.
So it looks as if the entire functionality should be oauth2.