PHPackages                             socialiteproviders/azureadb2c - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. socialiteproviders/azureadb2c

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

socialiteproviders/azureadb2c
=============================

AzureADB2C OAuth2 Provider for Laravel Socialite

4.6.0(2mo ago)2108.7k↓30.9%14MITPHPPHP ^8.0

Since Oct 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/SocialiteProviders/AzureADB2C)[ Packagist](https://packagist.org/packages/socialiteproviders/azureadb2c)[ RSS](/packages/socialiteproviders-azureadb2c/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (0)

Azure AD B2C
============

[](#azure-ad-b2c)

```
composer require socialiteproviders/azureadb2c
```

Installation &amp; Basic Usage
------------------------------

[](#installation--basic-usage)

Please see the [Base Installation Guide](https://socialiteproviders.com/usage/), then follow the provider specific instructions below.

### Add configuration to `config/services.php`

[](#add-configuration-to-configservicesphp)

```
'azureadb2c' => [
    'client_id' => env('AADB2C_ClientId'),
    'client_secret' => env('AADB2C_ClientSecret'),
    'redirect' => env('AADB2C_RedirectUri'),
    'domain' => env('AADB2C_Domain'),  // {your_domain}.b2clogin.com
    'policy' => env('AADB2C_Policy'),  // such as 'b2c_1_user_susi'
    'default_algorithm' => env('AADB2C_DefaultAlgorithm', 'RS256'), // decoding algorithm JWK key such as 'RS256'
    'custom_domain' => env('AADB2C_CUSTOM_DOMAIN'), // optional - set to use your custom domain e.g. login.contoso.com
    'tenant' => env('AADB2C_TENANT'), // optional - set to use your tenant ID or custom domain in place of the default onmicrosoft.com one
],
```

To set up your Azure AD B2C custom domain, follow [these instructions](https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-domain?pivots=b2c-user-flow).

### Add provider event listener

[](#add-provider-event-listener)

#### Laravel 11+

[](#laravel-11)

In Laravel 11, the default `EventServiceProvider` provider was removed. Instead, add the listener using the `listen` method on the `Event` facade, in your `AppServiceProvider` `boot` method.

- Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.

```
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('azureadb2c', \SocialiteProviders\AzureADB2C\Provider::class);
});
```

Laravel 10 or below Configure the package's listener to listen for `SocialiteWasCalled` events. Add the event to your `listen[]` array in `app/Providers/EventServiceProvider`. See the [Base Installation Guide](https://socialiteproviders.com/usage/) for detailed instructions.

```
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\AzureADB2C\AzureADB2CExtendSocialite::class.'@handle',
    ],
];
```

### Usage

[](#usage)

You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):

Redirect to Azure AD B2C

```
return Socialite::driver('azureadb2c')->redirect();
```

Callback

```
$provided_user = Socialite::driver('azureadb2c')->user();
```

Logout

```
return redirect(Socialite::driver('azureadb2c')->logout('http://localhost'));
```

### Returned User fields

[](#returned-user-fields)

- `sub`
- `name`

Note) 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);
    }
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance83

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~226 days

Recently: every ~236 days

Total

8

Last Release

89d ago

PHP version history (2 changes)4.0.0PHP ^7.4 || ^8.0

4.4.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/65eb3a7ba2a2c13b3a9de48b836caf759ad4052f9a839e30464c80d177d5b3d2?d=identicon)[atymic](/maintainers/atymic)

---

Top Contributors

[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (13 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (5 commits)")[![lsmith77](https://avatars.githubusercontent.com/u/300279?v=4)](https://github.com/lsmith77 "lsmith77 (2 commits)")[![fujie](https://avatars.githubusercontent.com/u/1155514?v=4)](https://github.com/fujie "fujie (1 commits)")[![kurucu](https://avatars.githubusercontent.com/u/1073323?v=4)](https://github.com/kurucu "kurucu (1 commits)")[![esseremmerik](https://avatars.githubusercontent.com/u/3390371?v=4)](https://github.com/esseremmerik "esseremmerik (1 commits)")[![cwp-jamesh](https://avatars.githubusercontent.com/u/118472134?v=4)](https://github.com/cwp-jamesh "cwp-jamesh (1 commits)")[![maks-oleksyuk](https://avatars.githubusercontent.com/u/90793591?v=4)](https://github.com/maks-oleksyuk "maks-oleksyuk (1 commits)")[![shealavington](https://avatars.githubusercontent.com/u/16869302?v=4)](https://github.com/shealavington "shealavington (1 commits)")[![vincent-paqt](https://avatars.githubusercontent.com/u/138566995?v=4)](https://github.com/vincent-paqt "vincent-paqt (1 commits)")[![zulficarjoy](https://avatars.githubusercontent.com/u/54574546?v=4)](https://github.com/zulficarjoy "zulficarjoy (1 commits)")

---

Tags

laraveloauthoauth1oauth2social-mediasocialitesocialite-providerslaravelprovideroauthsocialiteOpenID Connectazure-adazure active directorylaravel socialiteAzure Active Directory B2CAzure AD B2Claravel Azure AD B2Csocialite Azure AD B2C

### Embed Badge

![Health badge](/badges/socialiteproviders-azureadb2c/health.svg)

```
[![Health](https://phpackages.com/badges/socialiteproviders-azureadb2c/health.svg)](https://phpackages.com/packages/socialiteproviders-azureadb2c)
```

###  Alternatives

[socialiteproviders/apple

Apple OAuth2 Provider for Laravel Socialite

618.4M8](/packages/socialiteproviders-apple)[socialiteproviders/microsoft

Microsoft OAuth2 Provider for Laravel Socialite

326.1M13](/packages/socialiteproviders-microsoft)[socialiteproviders/instagram

Instagram OAuth2 Provider for Laravel Socialite

421.9M5](/packages/socialiteproviders-instagram)[kovah/laravel-socialite-oidc

OpenID Connect OAuth2 Provider for Laravel Socialite

2073.7k](/packages/kovah-laravel-socialite-oidc)[socialiteproviders/kakao

Kakao OAuth2 Provider for Laravel Socialite

10484.7k4](/packages/socialiteproviders-kakao)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
