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

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

iamprashant/slack-oauth2
========================

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

v1.2(3y ago)017MITPHPPHP &gt;=7.4.0

Since Jan 8Pushed 3y ago1 watchersCompare

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

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

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

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

This package is based on League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client) with Slack v2 api.

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

[](#installation)

```
$ composer require iamprashant/oauth2-slack
```

Usage
-----

[](#usage)

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

### Authorize Url generation

[](#authorize-url-generation)

```
$provider = new \IamPrashant\OAuth2\Client\Provider\Slack([
    'clientId'          => '{client-id}',
    'clientSecret'      => '{client-secret}',
    'redirectUri'       => '{callback-url}',
]);

// to get authorization url
$authUrl = $provider->getAuthorizationUrl();

// if you need to request the user_scope also with global scope
$authUrl = $provider->getAuthorizationUrl(["user_scope"=>"users.profile:read,users:read.email,users:read,im:history"]);

// can request with global scope

$authUrl = $provider->getAuthorizationUrl(['scope' => 'user:read user:write file:write', "user_scope"=>"users.profile:read,users:read.email,users:read,im:history"]);
```

### Authorization Flow

[](#authorization-flow)

```
$provider = new \IamPrashant\OAuth2\Client\Provider\Slack([
    'clientId'          => '{client-id}',
    'clientSecret'      => '{client-secret}',
    'redirectUri'       => '{callback-url}',
]);

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

    // token requested
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);
    //  Token object will contains channels (if webhoooks enable) and team
    try {
        // to get user details with complete informaiton
        $user = $provider->getResourceOwner($token);
        // Use these details to create a new profile
        var_dump($user);
    } catch (Exception $e) {
        // Failed to get user details
        exit('something got unexpected');
    }

    var_dump($token->getToken());
}
```

Contributing
------------

[](#contributing)

Feel free to create pull request, Thanks for contributing.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Total

3

Last Release

1217d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ad4ccdf306524909b9ab685da8a6f74de8f13bda484301f12d27b73afd6f880d?d=identicon)[iamprashant](/maintainers/iamprashant)

---

Tags

AuthenticationslackSSOidentityoauthoauth2authorizationidpsingle sign onslack-api

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[adam-paterson/oauth2-slack

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

22694.8k5](/packages/adam-paterson-oauth2-slack)

PHPackages © 2026

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