Microsoft account social connection "invalid_request" error

Problem statement

We are setting up a Microsoft account social connection per this doc:

https://marketplace.auth0.com/integrations/microsoft-account-social-connection

We believe the connection is configured properly but we are seeing an “invalid_request” error.

Solution

In the Fetch User Profile Script, first decode the ctx.id_token and use the values to populate the Auth0 user profile.

Example:

function(accessToken, ctx, cb) {
  	const jwt = require('jsonwebtoken');
  	const idToken = jwt.decode(ctx.id_token);
    const profile = {
      user_id: idToken.oid,
      email: idToken.email,
      name: idToken.name
    };
    cb(null, profile);
}