PHPackages                             webfiori/oauth - 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. webfiori/oauth

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

webfiori/oauth
==============

OAuth2 client library for PHP

v1.0.0(8mo ago)0891MITPHPPHP &gt;=8.1CI passing

Since Sep 3Pushed 8mo agoCompare

[ Source](https://github.com/WebFiori/oauth)[ Packagist](https://packagist.org/packages/webfiori/oauth)[ RSS](/packages/webfiori-oauth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (4)Used By (1)

WebFiori OAuth2 Library
=======================

[](#webfiori-oauth2-library)

 [![PHP Version](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565) [![Latest Version](https://camo.githubusercontent.com/0decec35866e6cba83c9e996b86287ea19b71caa541cccea2a3e86ccc47eadf3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656266696f72692f6f61757468)](https://camo.githubusercontent.com/0decec35866e6cba83c9e996b86287ea19b71caa541cccea2a3e86ccc47eadf3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656266696f72692f6f61757468) [![Total Downloads](https://camo.githubusercontent.com/2a5b7868b337a1decefcde61341f286cd8f6b5745278a9207391b35ebdbf99bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656266696f72692f6f61757468)](https://camo.githubusercontent.com/2a5b7868b337a1decefcde61341f286cd8f6b5745278a9207391b35ebdbf99bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656266696f72692f6f61757468) [![License](https://camo.githubusercontent.com/37292c2eb2fde1b8fd3181b420aae6f7f4ed0eb61936455e0cf9ee43c3508f80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f57656246696f72692f6f61757468)](https://camo.githubusercontent.com/37292c2eb2fde1b8fd3181b420aae6f7f4ed0eb61936455e0cf9ee43c3508f80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f57656246696f72692f6f61757468)

 [ ![](https://github.com/WebFiori/oauth/actions/workflows/php84.yaml/badge.svg?branch=main) ](https://github.com/WebFiori/oauth/actions) [ ![](https://camo.githubusercontent.com/8ea6c710b9304c660eae6b83003923f294cd9d8329ac470ba1e9c522313a1e77/68747470733a2f2f636f6465636f762e696f2f67682f57656246696f72692f6f617574682f6272616e63682f6d61696e2f67726170682f62616467652e737667) ](https://codecov.io/gh/WebFiori/oauth) [ ![](https://camo.githubusercontent.com/cd5b05f3511328a2a1c34798e67e8f65e52b5f60599ec3adeaaee1c625186aa6/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d57656246696f72695f6f61757468266d65747269633d616c6572745f737461747573) ](https://sonarcloud.io/dashboard?id=WebFiori_oauth)

An easy-to-use OAuth2 client library for PHP. Simplify OAuth2 authentication flows with support for multiple providers and token storage.

✨ Features
----------

[](#-features)

- 🔐 **OAuth2 Authorization Code Flow** - Complete implementation
- 🏢 **Multiple Providers** - Built-in support for Microsoft, Google, and GitHub
- 🔄 **Token Management** - Secure token storage and retrieval
- 🔧 **Extensible** - Easy to add custom OAuth2 providers

📋 Table of Contents
-------------------

[](#-table-of-contents)

- [Supported PHP Versions](#-supported-php-versions)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Providers](#-providers)
- [Token Storage](#-token-storage)
- [Multi-Provider Management](#-multi-provider-management)
- [API Reference](#-api-reference)
- [Examples](#-examples)

Supported PHP Versions
----------------------

[](#supported-php-versions)

Build Status[![](https://github.com/WebFiori/oauth/actions/workflows/php81.yaml/badge.svg?branch=main)](https://github.com/WebFiori/oauth/actions/workflows/php81.yaml)[![](https://github.com/WebFiori/oauth/actions/workflows/php82.yaml/badge.svg?branch=main)](https://github.com/WebFiori/oauth/actions/workflows/php82.yaml)[![](https://github.com/WebFiori/oauth/actions/workflows/php83.yaml/badge.svg?branch=main)](https://github.com/WebFiori/oauth/actions/workflows/php83.yaml)[![](https://github.com/WebFiori/oauth/actions/workflows/php84.yaml/badge.svg?branch=main)](https://github.com/WebFiori/oauth/actions/workflows/php84.yaml)🚀 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require webfiori/oauth
```

### Requirements

[](#requirements)

- PHP 8.1 or higher
- cURL extension

⚡ Quick Start
-------------

[](#-quick-start)

### Basic OAuth2 Flow

[](#basic-oauth2-flow)

```
