PHPackages                             bramdevries/oauth2-slack - 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. bramdevries/oauth2-slack

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

bramdevries/oauth2-slack
========================

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

0.1.0(10y ago)935.7k↓29.5%4[1 issues](https://github.com/bramdevries/oauth2-slack/issues)MITPHPPHP &gt;=5.5.0

Since Aug 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/bramdevries/oauth2-slack)[ Packagist](https://packagist.org/packages/bramdevries/oauth2-slack)[ RSS](/packages/bramdevries-oauth2-slack/feed)WikiDiscussions master Synced 1mo ago

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

Slack Provider for OAuth 2.0 Client
===================================

[](#slack-provider-for-oauth-20-client)

[![Latest Version](https://camo.githubusercontent.com/124e5fe8427487e8eec4a715768fbb2dcfdfc24c8b9f6ff85d9b4d5064f60260/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6272616d646576726965732f6f61757468322d736c61636b2e7376673f7374796c653d666c61742d737175617265)](https://github.com/bramdevries/oauth2-slack/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/23a3a40ddd10669bb4f2a9ebaf9abe72a7d1f6ba934426685b5c68406f031acf/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6272616d646576726965732f6f61757468322d736c61636b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bramdevries/oauth2-slack)[![Total Downloads](https://camo.githubusercontent.com/041f52b6eb3b20147c3769a31ad4a1e2357a3874eb6e6efabe346d090bd9bfb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6272616d646576726965732f6f61757468322d736c61636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bramdevries/oauth2-slack)

This package provides Slack 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 bramdevries/oauth2-slack

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new League\OAuth2\Client\Provider\Slack([
    'clientId'          => '{slack-client-id}',
    'clientSecret'      => '{slack-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
]);

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->getNickname());

    } 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

[](#managing-scopes)

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

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['identify','read','post'] // 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](https://api.slack.com/docs/oauth).

- identify
- read
- post
- client
- admin

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Credits
-------

[](#credits)

- [Bram Devries](https://github.com/bramdevries)
- [All Contributors](https://github.com/bramdevries/oauth2-slack/contributors)

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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

3914d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/041cdc8fc831716b7f56c3ddf84169ea1d97ca91e9ea90b42be88d73c404ff8a?d=identicon)[bramdevries](/maintainers/bramdevries)

---

Top Contributors

[![bramdevries](https://avatars.githubusercontent.com/u/1002245?v=4)](https://github.com/bramdevries "bramdevries (7 commits)")[![cossou](https://avatars.githubusercontent.com/u/1337112?v=4)](https://github.com/cossou "cossou (1 commits)")

---

Tags

clientslackoauthoauth2authorizationauthorisation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bramdevries-oauth2-slack/health.svg)

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

###  Alternatives

[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

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

1132.5M6](/packages/patrickbussmann-oauth2-apple)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[omines/oauth2-gitlab

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

36721.5k13](/packages/omines-oauth2-gitlab)

PHPackages © 2026

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