-
Notifications
You must be signed in to change notification settings - Fork 915
Closed
Labels
Description
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:
- 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)
- 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) - 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' }];