PHPackages                             alexmasterov/oauth2-stackexchange - 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. alexmasterov/oauth2-stackexchange

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

alexmasterov/oauth2-stackexchange
=================================

The Stack Exchange OAuth 2.0 Client Provider for The PHP League OAuth2-Client

0.1.0(9y ago)21702MITPHP

Since Feb 4Pushed 8y agoCompare

[ Source](https://github.com/AlexMasterov/oauth2-stackexchange)[ Packagist](https://packagist.org/packages/alexmasterov/oauth2-stackexchange)[ RSS](/packages/alexmasterov-oauth2-stackexchange/feed)WikiDiscussions master Synced 4w ago

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

StackExchange.com Provider for the OAuth 2.0 Client
===================================================

[](#stackexchangecom-provider-for-the-oauth-20-client)

[![Latest Stable Version](https://camo.githubusercontent.com/46b63ceafc9daf3b5863bada434fb894066b86cec38e7c42cf51ab5c0147388e/68747470733a2f2f706f7365722e707567782e6f72672f616c65786d61737465726f762f6f61757468322d737461636b65786368616e67652f762f737461626c65)](https://packagist.org/packages/alexmasterov/oauth2-stackexchange)[![License](https://camo.githubusercontent.com/24029a5d0155c1f0d6ba554a455da35bbfb4a42368b6ca3ccfb5e13b6d9eba83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616c65786d61737465726f762f6f61757468322d737461636b65786368616e67652e737667)](https://github.com/AlexMasterov/oauth2-stackexchange/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/3499be550d8b0551b93f2f8aa3ad771ab010774ec07ed2558bd55e18d817b89b/68747470733a2f2f7472617669732d63692e6f72672f416c65784d61737465726f762f6f61757468322d737461636b65786368616e67652e737667)](https://travis-ci.org/AlexMasterov/oauth2-stackexchange)[![Code Coverage](https://camo.githubusercontent.com/ac00b134fd634cb120ecf52fae4a9e37c361bf9222aed43f13efe00bc87eff32/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c65784d61737465726f762f6f61757468322d737461636b65786368616e67652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/AlexMasterov/oauth2-stackexchange/?branch=master)[![Code Quality](https://camo.githubusercontent.com/8e6e5028e69fc95c03c61953b458c6aeb3148c94f07c1353076af690300d474b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c65784d61737465726f762f6f61757468322d737461636b65786368616e67652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/AlexMasterov/oauth2-stackexchange/?branch=master)

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

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

[](#installation)

The suggested installation method is via [composer](https://getcomposer.org/):

```
composer require alexmasterov/oauth2-stackexchange
```

Usage
-----

[](#usage)

### Configuration

[](#configuration)

```
$provider = new AlexMasterov\OAuth2\Client\Provider\StackExchange([
    'clientId'     => '{client_id}',
    'clientSecret' => '{client_secret}',
    'redirectUri'  => '{redirect_uri}',
    'state'        => '{state}',
    'key'          => '{key}',
    'site'         => '{site}',
]);
```

### Authorization

[](#authorization)

```
if (!empty($_GET['error'])) {
    // Got an error, probably user denied access
    exit('Got error: ' . $_GET['error']);
}

if (empty($_GET['code'])) {
    // If we don't have an authorization code then get one
    $provider->authorize();
}

// 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 owner details
    $ownerDetails = $provider->getResourceOwner($token);
} catch (\Exception $e) {
    // Failed to get user details
    exit('Something went wrong: ' . $e->getMessage());
}

// Use this to interact with an API on the users behalf
echo $token->accessToken;
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

3434d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c3a759788edb549b16d53cc92214268ed89b6dbaa8dfa7025c3b5389bd34edf?d=identicon)[AlexMasterov](/maintainers/AlexMasterov)

---

Top Contributors

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

---

Tags

league-oauth2oauth2oauth2-provideroauth2-stackexchangeclientAuthenticationoauthoauth2authorizationstackoverflowstackExchange

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alexmasterov-oauth2-stackexchange/health.svg)

```
[![Health](https://phpackages.com/badges/alexmasterov-oauth2-stackexchange/health.svg)](https://phpackages.com/packages/alexmasterov-oauth2-stackexchange)
```

###  Alternatives

[league/oauth2-google

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

42222.6M158](/packages/league-oauth2-google)[cakedc/oauth2-cognito

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

18615.2k](/packages/cakedc-oauth2-cognito)

PHPackages © 2026

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