Custom OAuth2 Social connection with Cognito returning error "Invalid user id"

Problem statement

We are setting up a Custom OAuth2 Social connection with Cognito, and when attempting to log in with it we saw an error page with “Invalid user id”.


This error was occurring because a fetch user profile script had not been implemented for the connection:

function(accessToken, ctx, cb) {
    const profile = {};
    // Call OAuth2 API with the accessToken and create the profile
    cb(null, profile);


Properly configuring the fetch user profile script resolved this issue: