# Using Lock widget for Username-Password-Authentication connection, unable to get JWT access token

**URL:** <https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322>\
**Category:** Get Help\
**Tags:** jwt, access-token\
**Created:** [April 22, 2017, 5:26am UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322 "2017-04-22T05:26:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![developers](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@developers](https://community.auth0.com/u/developers)\
**Post date:** [April 22, 2017, 5:26am UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/1 "2017-04-22T05:26:33Z")

</div>

Hi guys,

I am using the Lock 10.13 widget to authenticate and get id tokens and access tokens. I’ve successfully enabled Google, Facebook and Twitter connections to return back full JWT access tokens, but when using the Username-Password-Authentication connection for login, I only ever get back short, opaque access tokens. The configuration params I’m passing the Auth0Lock instance is as follows:

```
options = {
    clientID: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    domain: 'xxxxxxxx.auth0.com',
    auth: {
      responseType: 'id_token token',
      audience: 'https://stoic.xxxxxxxx.com/',
      params: {
        responseType: 'id_token token', // For social, must be here.
        audience: 'https://stoic.xxxxxxxxxx.com/', // For social, must be here.
        scope: 'openid email picture user_metadata app_metadata access:xxxxxx_api' // offline_access.
      }
    },

    loginAfterSignUp: false // Wait for email verification.
};

```

I get this kind of response when using the Username-Password-Authentication connection in the widget.

```
{accessToken: "p2DaEIo4zvogf-vK", idToken: "eyJ0eXAiOiJKV1QiLCxxxxxxxxxxxxxxxxsImtpZCI6Ik56Zz…MaJwNAbr6gupxsG4G44PnAInPyx46Jxze-osBvlI3jqRuooQw", idTokenPayload: Object, refreshToken: undefined, state: undefined}

```

What else do I need to do to get my connection to return back JWT access tokens, instead of the short token?

Cheers,  
Mark

---

<div class="post-metadata">

**Author:** ![amaanc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/amaanc/32/6363_2.png) [@amaanc](https://community.auth0.com/u/amaanc)\
**Post date:** [April 24, 2017, 7:56pm UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/2 "2017-04-24T19:56:58Z")

</div>

Hey Mark!

We _highly_ recommend against allowing users to enter their credentials on the client (your app) itself instead of on the Authorization Server (on Auth0) or on the external Identity-Provider. This is because it’s a significantly more secure approach - vulnerabilities in client applications won’t necessarily compromise your user credentials, you’ll have better CSRF protection, and full support for SSO.

Our recommended approach is to use [Auth0’s Hosted Pages](https://auth0.com/docs/hosted-pages) - you can customized the Hosted Login Page as you please visually and on your client, your code simplifies to just the following:

```
webAuth.authorize({
  audience: 'https://mystore.com/api/v2',
  scope: 'read:order write:order',
  responseType: 'token',
  redirectUri: 'https://example.com/auth/callback'
});

```

See [the auth0.js repo](https://github.com/auth0/auth0.js#auth0webauth) and [our docs](https://auth0.com/docs/libraries/auth0js/v8) for more info.

* * *

For some additional information; the reason you’re seeing the behavior that you see is because currently, Lock’s username-password based authentication doesn’t use the new [API Authorization features](https://auth0.com/docs/api-auth).  
We’re working on more secure alternatives which will support this scenario with the API Authorization features too, but even with the upcoming alternatives, we will continue to recommend Hosted Pages for the most secure auth flows.

---

<div class="post-metadata">

**Author:** ![amaanc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/amaanc/32/6363_2.png) [@amaanc](https://community.auth0.com/u/amaanc)\
**Post date:** [April 24, 2017, 7:58pm UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/3 "2017-04-24T19:58:04Z")

</div>

Internal comment: I’m avoiding mention of the `oidcConformant` flag and avoiding mentioning [embedded login approaches as per this](https://auth0.slack.com/archives/C4DE36TPY/p1492705503826552)

---

<div class="post-metadata">

**Author:** ![developers](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@developers](https://community.auth0.com/u/developers)\
**Post date:** [April 25, 2017, 6:22am UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/4 "2017-04-25T06:22:37Z")

</div>

OK, thanks for the info. So it’s not recommended to use the Lock widget on my own site for entering in email/username and passwords (using the Username-Password-Authentication connection)?

I actually did figure out how to simulate the OAuth flow using the oidcConformant flag, so I’m now getting compliant OAuth responses and access\_token values. But I don’t want to do it the wrong way.

---

<div class="post-metadata">

**Author:** ![developers](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@developers](https://community.auth0.com/u/developers)\
**Post date:** [April 25, 2017, 6:22am UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/5 "2017-04-25T06:22:37Z")

</div>

OK, thanks for the info. So it’s not recommended to use the Lock widget on my own site for entering in email/username and passwords (using the Username-Password-Authentication connection)?

I actually did figure out how to simulate the OAuth flow using the oidcConformant flag, so I’m now getting compliant OAuth responses and access\_token values. But I don’t want to do it the wrong way.

---

<div class="post-metadata">

**Author:** ![amaanc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/amaanc/32/6363_2.png) [@amaanc](https://community.auth0.com/u/amaanc)\
**Post date:** [April 25, 2017, 9:00am UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/6 "2017-04-25T09:00:46Z")

</div>

The `oidcConformant` flag allows you to use [Auth0’s extension to the Resource Owner password grant](https://auth0.com/docs/api-auth/tutorials/password-grant#realm-support) on the client-side - however, the password grant is meant for highly-trusted confidential clients (i.e. ones that can be fully trusted to keep user credentials and client secrets safe). Security-wise, unless you have a very compelling reason, there’s no reason to take that risk - it’s much easier and more secure to use the Hosted Login Page.

---

<div class="post-metadata">

**Author:** ![rzwink](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rzwink/32/4281_2.png) [@rzwink](https://community.auth0.com/u/rzwink)\
**Post date:** [August 3, 2017, 8:55pm UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/7 "2017-08-03T20:55:37Z")

</div>

We are also using OIDC conformant flag true and seeing this issue with Username-Password-Authentication connections. Can you please advise on how we can use Username-Password-Authentication for OIDC conformant connections?

---

<div class="post-metadata">

**Author:** ![rzwink](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rzwink/32/4281_2.png) [@rzwink](https://community.auth0.com/u/rzwink)\
**Post date:** [August 3, 2017, 8:55pm UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/8 "2017-08-03T20:55:37Z")

</div>

We are also using OIDC conformant flag true and seeing this issue with Username-Password-Authentication connections. Can you please advise on how we can use Username-Password-Authentication for OIDC conformant connections?

---

<div class="post-metadata">

**Author:** ![rzwink](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rzwink/32/4281_2.png) [@rzwink](https://community.auth0.com/u/rzwink)\
**Post date:** [August 3, 2017, 8:55pm UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/9 "2017-08-03T20:55:37Z")

</div>

We are also using OIDC conformant flag true and seeing this issue with Username-Password-Authentication connections. Can you please advise on how we can use Username-Password-Authentication for OIDC conformant connections?

---

<div class="post-metadata">

**Author:** ![rzwink](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rzwink/32/4281_2.png) [@rzwink](https://community.auth0.com/u/rzwink)\
**Post date:** [August 3, 2017, 8:55pm UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/10 "2017-08-03T20:55:37Z")

</div>

We are also using OIDC conformant flag true and seeing this issue with Username-Password-Authentication connections. Can you please advise on how we can use Username-Password-Authentication for OIDC conformant connections?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/using-lock-widget-for-username-password-authentication-connection-unable-to-get-jwt-access-token/6322/11 "2018-03-02T05:53:26Z")

</div>


