Download the PHP package wohali/oauth2-discord-new without Composer
On this page you can find all versions of the php package wohali/oauth2-discord-new. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wohali/oauth2-discord-new
More information about wohali/oauth2-discord-new
Files in wohali/oauth2-discord-new
Package oauth2-discord-new
Short Description Discord OAuth 2.0 Client Provider for The PHP League OAuth2-Client
License MIT
Informations about the package oauth2-discord-new
Discord Provider for OAuth 2.0 Client
This package provides Discord OAuth 2.0 support for the PHP League's OAuth 2.0 Client, v2.0 and up.
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
To install, use composer:
Usage
Usage is the same as The League's OAuth client, using \Wohali\OAuth2\Client\Provider\Discord
as the provider.
Sample Authorization Code Flow
This self-contained example:
- Gets an authorization code
- Gets an access token using the provided authorization code
- Looks up the user's profile with the provided access token
You can try this script by registering a Discord App 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.
Managing Scopes
When creating your Discord authorization URL in Step 1, you can specify the state and scopes your application may authorize.
If neither are defined, the provider will utilize internal defaults.
At the time of authoring this documentation, the following scopes are available:
- bot
- connections
- identify
- guilds
- guilds.join
- gdm.join
- messages.read
- rpc
- rpc.api
- rpc.notifications.read
- webhook.incoming
Refreshing a Token
You can refresh an expired token using a refresh token rather than going through the entire process of obtaining a brand new token. To do so, simply reuse the fresh token from your data store to request a refresh:
Client Credentials Grant
Discord provides a client credentials flow for bot developers to get their own bearer tokens for testing purposes. This returns an access token for the bot owner:
Bot Authorization
To authorize a bot, specify a scope of bot
and set permissions appropriately:
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.