PHPackages                             loicboursin/oauth2-microsoft-graph - 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. loicboursin/oauth2-microsoft-graph

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

loicboursin/oauth2-microsoft-graph
==================================

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

v1.0.3(2y ago)26.7k—3.3%1MITPHPPHP &gt;=8.0

Since May 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/LoicBoursin/oauth2-microsoft-graph)[ Packagist](https://packagist.org/packages/loicboursin/oauth2-microsoft-graph)[ RSS](/packages/loicboursin-oauth2-microsoft-graph/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (4)Versions (7)Used By (0)

Microsoft Graph Provider for OAuth 2.0 Client
=============================================

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

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

Requirements
------------

[](#requirements)

The following versions of PHP are compatible:

- PHP 8.2
- PHP 8.1
- PHP 8.0

Newer versions may be compatible but have not been tested.

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

[](#installation)

To install, use composer:

```
composer require LoicBoursin/oauth2-microsoft-graph

```

Usage
-----

[](#usage)

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

#### Managing Scopes and State

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

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

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

At the time of authoring this documentation, the following scopes are available (most important ones) :

- openid
- email
- profile
- (Eventually) User.Read

#### Overriding default values

[](#overriding-default-values)

If you need to override the default values such as authorization URL or default scopes, you can do so by extending the provider through your own provider class, then overriding any of the properties or methods required, for example:

```
