Auth0 Home Blog Docs

Context.request.query with Universal login

Using Lock I can pass a value to Auth0 Rules using a property on the params object like this:

 var lockAuthOptions = {
        redirectUrl: "https://example.com",
        responseType: 'token id_token',
        params: {
            audience: 'http://myaudience',
            myproperty: "hello rule!!"
        }
    }

and access it in a rule like this:

function (user, context, callback) {
   var value = context.request.query.myproperty;
return callback(null, user, context);
}

How do I accomplish the same using Universal login and WebAuth?

var webAuth = new auth0.WebAuth({
        domain: "authodomain.com",
        clientID: "clientId",
        responseType: 'token id_token',
        params: {
            myproperty: "Not working"
        },
        myproperty: "Not working,
        audience: "https://myaudience",
        scope: "scopes",
        extraParams: { myproperty: "Not working" },
        state: "mystate",
        redirectUri: "http://example.com"
 });
webAuth.authorize();

Hi @sbf,

According to the Auth0.js docs you pass additional params when you call the authorize method:

webAuth.authorize({
  //Any additional options can go here
});

That should work. It was a little buried in the docs and took some work to find!

Let me know how it goes.

Thanks,
Dan

Thanks a lot! It works.

I’ve been staring at the table with the parameters in the documentation and overseen the black box below which you are referring to.

Thanks again,

Simon

Glad you got a solution :slight_smile: !

Best,
Dan

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.