Can you login using Javascript instead of a URL?

In my app I’m currently logging in users by redirecting the whole page to:${appKey}?connection=myCompany and then letting them fill in the form on the auth0 UI.

Can I use an auth0 API to log in using Javascript? Something like this?

import auth0Api from 'auth0/somewhereimaginary';
const username = usernameInput.value;
const password = passwordInput.value;
await auth0Api.login(username, password);

I’ve found this Cross-Origin Authentication which looks like it could be it but the page just has a load of text and then some irrelevant links at the bottom, but no JS code examples.

Hi @will.squire,

Welcome to the Auth0 Community!

You can exchange a username/password directly for a token using the Resource Owner Password Flow.

Let me know if you have any questions!