# Can you login using Javascript instead of a URL?

**URL:** <https://community.auth0.com/t/can-you-login-using-javascript-instead-of-a-url/86892>\
**Category:** Get Help\
**Created:** [July 13, 2022, 12:06pm UTC](https://community.auth0.com/t/can-you-login-using-javascript-instead-of-a-url/86892 "2022-07-13T12:06:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![will.squire](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/will.squire/32/38724_2.png) [@will.squire](https://community.auth0.com/u/will.squire)\
**Post date:** [July 13, 2022, 12:06pm UTC](https://community.auth0.com/t/can-you-login-using-javascript-instead-of-a-url/86892/1 "2022-07-13T12:06:53Z")

</div>

In my app I’m currently logging in users by redirecting the whole page to: `https://mycompany.eu.auth0.com/samlp/${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?

```auto
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](https://auth0.com/docs/authenticate/login/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.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 25, 2022, 10:14pm UTC](https://community.auth0.com/t/can-you-login-using-javascript-instead-of-a-url/86892/3 "2022-07-25T22:14:15Z")

</div>

Hi @will.squire,

Welcome to the Auth0 Community!

You can exchange a username/password directly for a token using the [Resource Owner Password Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow).

Let me know if you have any questions!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 5:22pm UTC](https://community.auth0.com/t/can-you-login-using-javascript-instead-of-a-url/86892/4 "2022-12-21T17:22:44Z")

</div>


