How populate data from social profile (Google, Facebook etc.) into user

Hi, I would like to add a few custom fields to a default user model and populate them with data from user’s social profile when he login using a social provider like Google or Facebook and Strapi creates a new user entry in database.

In Strapi dashboard I have add some fields to the default user model and if I populate them direct in dashboard those fields and their values will be a part of the user’s API response as expected.

The thing is, I want to populate those custom fields on user model when someone sign in with a provider and Strapi creates for that person a fresh user entity in database.

I have tried to extend user.js and providers.js under user-permission/services as well as auth.js controller but it didn’t work at all. The custom fields are still empty, and I don’t really have further idea how I could achieve my goal.

System Information
  • Strapi Version: 4.1.9
  • Database: Postgres

The solution was indeed quite easy but the required changes weren’t really obvious or documented. Additionally, the entire process of extending existing plugin in Strap v4 is not so well documented and can be cumbersome, at least. At the end:

Under src/extensions/user-permissions created directories and files as follows:

// strapi-server.js

module.exports = (plugin) => {["providers"] = require("./server/services/providers");
  return plugin;
// server/services/providers.js
// this file doesn't need to be changed, but it imports the file we need to change
// server/services/providers-list.js
case "google": {
      const google = purest({ provider: "google" });

      return google
        .then(({ body }) => ({
            avatar: body.picture

With that code:

  1. Google returns a user profile with last and first name and some additional info like link to user’s avatar.
  2. Using a login provider a new user can be created in the database using that additional info. In my case I extended base user model with avatar field, which then gets filled with data returned by Google.
1 Like

Could you show all code from files: server/services/providers.js and server/services/providers-list.js (if it still exist)?
I have same issue. So, I’ve created strapi-server.js like your, but I dont know what code put to server/services/providers.js