PHPackages                             wohali/oauth2-discord-new - 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. wohali/oauth2-discord-new

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

wohali/oauth2-discord-new
=========================

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

1.2.1(3y ago)116684.7k—9.4%20[4 PRs](https://github.com/wohali/oauth2-discord-new/pulls)11MITPHPPHP ^7.2|^8.0

Since Oct 16Pushed 1y ago7 watchersCompare

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

READMEChangelog (4)Dependencies (5)Versions (5)Used By (11)

Discord Provider for OAuth 2.0 Client
=====================================

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

[![Source Code](https://camo.githubusercontent.com/29a6381d451a86bb9e7fa1a20a28d4db1378d65f6dd68d3c176f4bd5be25b6c8/687474703a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d776f68616c692f6f61757468322d2d646973636f72642d2d6e65772d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/wohali/oauth2-discord-new)[![Latest Version](https://camo.githubusercontent.com/044d9beaa5339013976d7c75f529855710533042731cb77c69d5e6c62edb5e40/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f776f68616c692f6f61757468322d646973636f72642d6e65772e7376673f7374796c653d666c61742d737175617265)](https://github.com/wohali/oauth2-discord-new/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/09fdbf556c2299dff72dff03a8254de091238389ab3b6491fced651f463b10fe/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f776f68616c692f6f61757468322d646973636f72642d6e65772f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/wohali/oauth2-discord-new)[![Scrutinizer](https://camo.githubusercontent.com/421558f2ed444ebb41a878f56b61285463751a8fb7ab92b24f37f7a3e6b331bd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f776f68616c692f6f61757468322d646973636f72642d6e65772f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/wohali/oauth2-discord-new)[![Coverage Status](https://camo.githubusercontent.com/170e46b64fd1c2ebf7c35ac36aecb8ec5edd6bad0dc88803f01fd014a7edbe7e/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f776f68616c692f6f61757468322d646973636f72642d6e65772f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/wohali/oauth2-discord-new?branch=master)[![Total Downloads](https://camo.githubusercontent.com/1dfa92a61db2e0db8741f55d17baf6e8a4e346794824b37dcfebf6f4fa2ea14e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f68616c692f6f61757468322d646973636f72642d6e65772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wohali/oauth2-discord-new)

This package provides Discord OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client), v2.0 and up.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 7.2
- PHP 7.3
- PHP 7.4
- PHP 8.0
- PHP 8.1
- PHP 8.2

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

[](#installation)

To install, use composer:

```
$ composer require wohali/oauth2-discord-new
```

Usage
-----

[](#usage)

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

### Sample Authorization Code Flow

[](#sample-authorization-code-flow)

This self-contained example:

1. Gets an authorization code
2. Gets an access token using the provided authorization code
3. Looks up the user's profile with the provided access token

You can try this script by [registering a Discord App](https://discord.com/developers/applications/me/create) with a redirect URI to your server's copy of this sample script. Then, place the Discord app's client id and secret, along with that same URI, into the settings at the top of the script.

```
