Auth0 Home Blog Docs

401 auth.js v8

auth0js

#1

I have issues with tokenId with auth0js v8
that works fine:

 auth0 = new auth0.Authentication({
        domain: environment.auth0domain,
        clientID: environment.auth0clientID,
        responseType: 'token id_token',
        scope: 'openid name email offline_access'
    });

 public login(username: string, password: string): void {
        this.auth0.loginWithResourceOwner({
            realm: 'Username-Password-Authentication',
            username,
            password,
            owp: true,
            device: 't'
        }, (err, authResult) => {
           console.log(error, 'auth', authResult);
        });
    }

that works fine too

auth0 = new auth0.WebAuth({
            domain: environment.auth0domain,
            clientID: environment.auth0clientID,
            responseType: 'token id_token',
            scope: 'openid name email offline_access'
        });


public loginWithGoogle(): void {
        this.auth0.popup.authorize({
            owp: true,
            connection: 'some-name,
            device: 't'
        }, (error, authResult) => {
            console.log(error, 'auth', authResult);
        });
    }

that one doesnt work at all:

auth0 = new auth0.Authentication({
        domain: environment.auth0domain,
        clientID: environment.auth0clientID,
        responseType: 'token id_token',
        scope: 'openid name email offline_access'
    });

    public login(username: string, password: string): void {
        this.auth0.client.login({
            connection: 'Username-Password-Authentication',
            username,
            password,
            owp: true,
            device: 't'
        }, (err, authResult) => {
            console.log(error, 'auth', authResult);
        });
    }

If you take any their tokens and open https://{domain}.auth0.com/tokeninfo?id_token={token} first 2 works just fine so:

  • auth.Authentication + loginWithResourceOwner

  • auth.WebAuth + authorize

but

  • auth.WebAuth + login gives 401 with the token.

On the other hand whats the device param? I couldn’t find anything about that. One last thing that text editor for comments is really, really hard to use.

Anyway thanks in advance.


#2