I want to replace the auth0 provider method found in getInitialProviders() in node_modules/@strapi/plugin-users-permissions/server/services/providers-registry.js. Basically, I want to access all the properties returned by Auth0, not the tiny subset currently returned. Here is an example of my ‘alternative method’ that simply returns a _raw property with all of these data provided by Auth0.
That’s a really useful approach to know, thanks for taking the time to post it. I’ve been digging into the docs/source because I needed to customize the providers service to prevent duplicated usernames (when a local account exists say with username “john” and someone comes in from another provider, you can end up with duplicated usernames [known issue]). The username is also case insensitive so username Jon would still be allowed if a username jon was present via the admin panel.
The providers-registry generates/obtains the username for the various providers. The providers service then deals with creating the strapi user if required. I ended up doing it in strapi-server.js in the /extensions/users-permissions/strapi-server.js
Where providers is the strapi implementation from the node folder copied across and customized as required.
Interestingly I’ve just also noticed strapi will duplicate the email address (create two accounts with the same) if you have a local account already existing say jon@some_provider.com and you then log in with same provider for example, strapi will then still provision another account with the same email address. (but obviously with a differing provider stored - despite advanced settings set to force one account per email address), so that’s something else I’ll need to address for my use case. It’s a problem where people create an account locally (using a provider type address gmail for example) then later log in directly with a provider.
I do the same for Twitter by modifying your code as it uses OAuth 2.0 only for new app registrations and Strapi’s registry for Twitter does not support it.
Thanks for this method, I had to use this approach with providers-registry.js too because the one described by @haysclark didn’t work for me (it logged the console.log('My Auth0') meaning it was reaching this part, but then it gave me an error). It’s a pity since I liked this aproach more.
If using this approach, the strapi logs showed:
/api/connect/auth0/callback?code=XXX (863 ms) 302
And if using the overwriting the providers-registry.js service approach, the logs look like this: