Skip to content

Passing custom query parameters in authorize endpoint #341

@mtolkas

Description

@mtolkas

What problem does this feature solve?

The option to pass custom query params in the authorize endpoint (in this scenario for Auth0) can help in the following scenarios:

  1. Extract and use the params in Auth0 Rules (for example, on sign up, a parameter can be used to determine the Role that a user should be assigned to, via a Rule)
  2. Setting the language for the Universal Login page (by passing the relevant passcode via the language param, and then extracting it at the Auth0 side)
  3. Setting the audience in the configuration without the need to set a global one in the Auth0 dashboard (this point is also discussed here and is pending merge, but only for the audience param)

What does the proposed changes look like?

Looking at /lib/schemes/oauth2.js, method login(), we see that the options are hardcoded before passed for encoding.
Inside this opts object we can destructure the custom properties that we’ll want to pass to the authorize endpoint, like so:

  login () {
    const opts = {
      // no change needed, only adding the line below  
      ...(this.options.custom_props.length ? Object.assign({}, ...this.options.custom_props.map(el => el)): {}),
    }
     //no change needed

Then, in the app's code we can add an arbitrary set of query parameters like so:

this.$auth.strategies.auth0.options.custom_props = [{ customParamKey: 'customParamValue' }, { language: 'fr' }];
This feature request is available on Nuxt community (#c321)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions