0

I'm using Laravel Socialite and have added the azureadB2C service provider (https://github.com/SocialiteProviders/AzureADB2C).

The azureADB2C service provider expects a 'name' claim in the token from the B2C tenant but I am only providing first_name and given_name. I want to modify this by updating setRaw(), which is found in socialiteproviders/azureadb2c/Provider.php.

The documentation gives a brief clue on how to do this:

*If you want to add claim mappings, change User::setRaw() function. The claims mappings must be match with claims in id_token which Azure AD B2C returns.

public function setRaw($user)
{
    $user['name'] = $user['name'] ?: $user['given_name'].' '.$user['family_name'];
    $user['nickname'] = $user['name'] ?: '';
    $user['email'] = $user['emails'][0];

    return parent::setRaw($user);
}*

However, I cannot figure out how to do this and I'm really stumped. I believe I need to extend User::setRaw() but I really need an idiots guide on what to change and where to put the files please. Thanks so much!

1
  • To modify the claims mapping in Laravel Socialite AzureADB2C provider, you need to extend the User class and override the setRaw function. In the setRaw function, you can modify the claims mapping as needed to match the claims in the id_token returned by Azure AD B2C
    – Rukmini
    Commented Jun 4 at 8:40

0