PHPackages                             commandstring/discordoauth - 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. commandstring/discordoauth

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

commandstring/discordoauth
==========================

An easier way to use discord oauth in PHP

v1.0.1(3y ago)015MITPHP

Since Dec 31Pushed 3y ago1 watchersCompare

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

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

commandstring/discordoauth
==========================

[](#commandstringdiscordoauth)

An easier way to get discord OAuth tokens

Requirements
============

[](#requirements)

- PHP 8.1=&lt;
- Composer 2
- Registered Discord application

Getting Token
=============

[](#getting-token)

You will need to retrieve your discord application's `client_id` and `client_secret`. After retrieving those you can instantiate the `\CommandString\DiscordOAuth\OAuth` class.

```
$OAuth = (new OAuth("http://localhost:8000", $client_id, $client_secret));
```

You will then need to define scopes by using the `addScopes` method. You can either supply a scope string or supply a Scopes enum.

```
$OAuth->addScopes(Scopes::IDENTIFY);
```

Afterwards you can then generate a url for the authorize endpoint by invoking the `buildAuthorizeUrl` method.

```
$authUrl - $OAuth->buildAuthorizeUrl();
```

After the client is redirected you can then use the `getToken` method for retrieving the access token.

```
$tokenRes = $OAuth->getToken($_GET["code"]);
```

*You can supply your own `\React\Http\Browser` in the second argument of this method*

`$tokenRes` will be an stdClass with the following structure.

```
{
    "access_token": "",
    "expires_in": "",
    "refresh_token": "",
    "scope": "",
    "token_type": ""
}
```

You can also refresh your token with the refreshToken method...

```
$newTokenRes = $OAuth->refreshToken($tokenRes->refresh_token);
```

Getting user
============

[](#getting-user)

```
$user = User::getWithToken($tokenRes->token_type, $tokenRes->access_token);
```

*Note: All properties of the user are readonly.*

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Every ~6 days

Total

2

Last Release

1226d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1dc8515485fa64088fdfa03dd0f487d507dc1516824c31be2626a6ee25244dd?d=identicon)[command\_string](/maintainers/command_string)

---

Top Contributors

[![CommandString](https://avatars.githubusercontent.com/u/44886996?v=4)](https://github.com/CommandString "CommandString (3 commits)")

### Embed Badge

![Health badge](/badges/commandstring-discordoauth/health.svg)

```
[![Health](https://phpackages.com/badges/commandstring-discordoauth/health.svg)](https://phpackages.com/packages/commandstring-discordoauth)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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