PHPackages                             socialiteproviders/microsoft-azure - 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/microsoft-azure

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

socialiteproviders/microsoft-azure
==================================

Microsoft Azure OAuth2 Provider for Laravel Socialite

5.2.0(2y ago)556.0M—5.7%3317MITPHPPHP ^8.0

Since Jul 18Pushed 2mo ago5 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (18)Used By (17)

Azure
=====

[](#azure)

```
composer require socialiteproviders/microsoft-azure
```

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)

```
'azure' => [
  'client_id' => env('AZURE_CLIENT_ID'),
  'client_secret' => env('AZURE_CLIENT_SECRET'),
  'redirect' => env('AZURE_REDIRECT_URI'),
  'tenant' => env('AZURE_TENANT_ID'),
  'proxy' => env('PROXY')  // optionally
],
```

### 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('azure', \SocialiteProviders\Azure\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\Azure\AzureExtendSocialite::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):

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

To logout of your app and Azure:

```
public function logout(Request $request)
{
     Auth::guard()->logout();
     $request->session()->flush();
     $azureLogoutUrl = Socialite::driver('azure')->getLogoutUrl(route('login'));
     return redirect($azureLogoutUrl);
}
```

### Returned User fields

[](#returned-user-fields)

- `id`
- `name`
- `email`

Advanced usage
--------------

[](#advanced-usage)

In order to have multiple / different Active directories on Azure (i.e. multiple tenants) The same driver can be used but with a different config:

```
/**
 * Returns a custom config for this specific Azure AD connection / directory
 * @return \SocialiteProviders\Manager\Config
 */
function getConfig(): \SocialiteProviders\Manager\Config
{
  return new \SocialiteProviders\Manager\Config(
    env('AD_CLIENT_ID', 'some-client-id'), // a different clientID for this separate Azure directory
    env('AD_CLIENT_SECRET'), // a different secret for this separate Azure directory
    url(env('AD_REDIRECT_PATH', '/azuread/callback')), // the redirect path i.e. a different callback to the other azureAD callbacks
    ['tenant' => env('AD_TENANT_ID', 'common')], // this could be something special if need be, but can also be left out entirely
  );
}
//....//
Socialite::driver('azure')
    ->setConfig(getConfig())
    ->redirect();
```

This also applies to the callback for getting the user credentials that one has to remember to inject the `->setConfig($config)`-method i.e.:

```
$socialUser = Socialite::driver('azure')
    ->setConfig(getConfig())
    ->user();
```

If the application that you are authenticating against is anything other single tenant, use the following values in place of the tenant\_id:

- Multitenant applications: "organizations"
- Multitenant and personal accounts: "common"
- Personal accounts only: "consumers"

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance56

Moderate activity, may be stable

Popularity60

Solid adoption and visibility

Community35

Small or concentrated contributor base

Maturity77

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 ~210 days

Recently: every ~251 days

Total

16

Last Release

795d ago

Major Versions

1.0.x-dev → v2.0.02016-03-30

v2.0.3 → v3.0.02017-01-25

v3.1.0 → 4.0.02020-10-25

4.2.1 → 5.0.02021-10-05

PHP version history (5 changes)v1.0.0PHP &gt;=5.5.0

v2.0.0PHP ^5.6 || ^7.0

4.0.0PHP ^7.2

4.2.0PHP ^7.2 || ^8.0

5.2.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23558090?v=4)[Miguel Piedrafita](/maintainers/m1guelpf)[@m1guelpf](https://github.com/m1guelpf)

---

Top Contributors

[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (16 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (12 commits)")[![moisish](https://avatars.githubusercontent.com/u/15047879?v=4)](https://github.com/moisish "moisish (2 commits)")[![Jimbolino](https://avatars.githubusercontent.com/u/5860587?v=4)](https://github.com/Jimbolino "Jimbolino (1 commits)")[![jwjcmw](https://avatars.githubusercontent.com/u/2118746?v=4)](https://github.com/jwjcmw "jwjcmw (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![maks-oleksyuk](https://avatars.githubusercontent.com/u/90793591?v=4)](https://github.com/maks-oleksyuk "maks-oleksyuk (1 commits)")[![matalaweb](https://avatars.githubusercontent.com/u/4079247?v=4)](https://github.com/matalaweb "matalaweb (1 commits)")[![Max13](https://avatars.githubusercontent.com/u/531249?v=4)](https://github.com/Max13 "Max13 (1 commits)")[![robiiinos](https://avatars.githubusercontent.com/u/16455953?v=4)](https://github.com/robiiinos "robiiinos (1 commits)")[![saundefined](https://avatars.githubusercontent.com/u/4685504?v=4)](https://github.com/saundefined "saundefined (1 commits)")[![alessandrofuda](https://avatars.githubusercontent.com/u/23055785?v=4)](https://github.com/alessandrofuda "alessandrofuda (1 commits)")[![Tamas-hi](https://avatars.githubusercontent.com/u/36476318?v=4)](https://github.com/Tamas-hi "Tamas-hi (1 commits)")[![askmrsinh](https://avatars.githubusercontent.com/u/6129517?v=4)](https://github.com/askmrsinh "askmrsinh (1 commits)")[![fruitl00p](https://avatars.githubusercontent.com/u/1492861?v=4)](https://github.com/fruitl00p "fruitl00p (1 commits)")

---

Tags

laraveloauthoauth1oauth2social-mediasocialitesocialite-providerslaravelprovideroauthsocialitemicrosoftazure

### Embed Badge

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

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

###  Alternatives

[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)
