PHPackages                             b3-it/oauth2-adfs - 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. b3-it/oauth2-adfs

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

b3-it/oauth2-adfs
=================

Microsoft Active Directory Federation Service (ADFS) OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1.0.1.0(2y ago)640.9k↓36%2MITPHPCI failing

Since May 15Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/b3-it/oauth2-adfs)[ Packagist](https://packagist.org/packages/b3-it/oauth2-adfs)[ RSS](/packages/b3-it-oauth2-adfs/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Microsoft ADFS Provider for OAuth 2.0 Client
============================================

[](#microsoft-adfs-provider-for-oauth-20-client)

[![Latest Version](https://camo.githubusercontent.com/54576df2417314c0b4822944237b52b2a4b7f18b49c31c39c627c200b9cf0ef3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62332d69742f6f61757468322d616466732e7376673f7374796c653d666c61742d737175617265)](https://github.com/b3-it/oauth2-adfs/releases)[![Coverage Status](https://camo.githubusercontent.com/25a761fb6e5410b446e6399966f21cbced21c834d922687644e0832afadf5f6c/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f7468657068706c65616775652f6f61757468322d636c69656e742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/b3-it/oauth2-adfs?branch=master)[![Total Downloads](https://camo.githubusercontent.com/8cce7b90299748fad4267ec3e87039ea80dd344297c4713b772dfa5d5096654c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62332d69742f6f61757468322d616466732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/b3-it/oauth2-adfs)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/b3-it/oauth2-adfs/blob/master/LICENSE)

This package provides Microsoft ADFS OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

Installation
------------

[](#installation)

To install, use composer:

```
composer require b3-it/oauth2-adfs

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\B3it\OAuth2\Client\Provider\Adfs` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new B3it\OAuth2\Client\Provider\Adfs([
    // Required
    'clientId'                  => '{microsoft-client-id}',
    'clientSecret'              => '{microsoft-client-secret}',
    'authServerUrl'             => 'https://my.ms-server.de/adfs',
    // Optional
    'redirectUri'               => 'https://example.com/callback-url',
    'resource'                  => 'https://example.com'

]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        printf('Hello %s!', $user->geName());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}
```

#### Managing Scopes and State

[](#managing-scopes-and-state)

When creating your Microsoft ADFS authorization URL, you can specify the state and scopes your application may authorize.

```
$options = [
    'scope' => ['allatclaims', 'openid'] // array or string
];

$authorizationUrl = $provider->getAuthorizationUrl($options);
```

If neither are defined, the provider will utilize internal defaults.

At the time of authoring this documentation, the following scopes are available.

##### Scopes

[](#scopes)

- logon\_cert
- aza
- allatclaims
- email
- profile
- winhello\_cert
- openid
- vpn\_cert
- user\_impersonation

Credits
-------

[](#credits)

- [B3 IT Systeme GmbH](https://github.com/b3-it)
- [All Contributors](https://github.com/b3-it/oauth2-adfs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/b3-it/oauth2-adfs/blob/master/LICENSE) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance50

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

2

Last Release

795d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3726836?v=4)[Frank Rochlitzer](/maintainers/theroch)[@theroch](https://github.com/theroch)

---

Top Contributors

[![theroch](https://avatars.githubusercontent.com/u/3726836?v=4)](https://github.com/theroch "theroch (11 commits)")

---

Tags

clientoauthoauth2microsoftauthorizationauthorisationadfs

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/b3-it-oauth2-adfs/health.svg)

```
[![Health](https://phpackages.com/badges/b3-it-oauth2-adfs/health.svg)](https://phpackages.com/packages/b3-it-oauth2-adfs)
```

###  Alternatives

[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

25310.7M83](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[stevenmaguire/oauth2-microsoft

Microsoft OAuth 2.0 Client Provider for The PHP League OAuth2-Client

742.6M18](/packages/stevenmaguire-oauth2-microsoft)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1152.8M12](/packages/patrickbussmann-oauth2-apple)[omines/oauth2-gitlab

GitLab OAuth 2.0 Client Provider for The PHP League OAuth2-Client

36779.2k16](/packages/omines-oauth2-gitlab)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

261.8M1](/packages/mollie-oauth2-mollie-php)

PHPackages © 2026

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