Download the PHP package sluther/oauth2-reddit without Composer
On this page you can find all versions of the php package sluther/oauth2-reddit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sluther/oauth2-reddit
More information about sluther/oauth2-reddit
Files in sluther/oauth2-reddit
Package oauth2-reddit
Short Description Reddit OAuth2 provider for league/oauth2-client
License MIT
Informations about the package oauth2-reddit
Reddit OAuth2 Provider
This package provides Reddit integration for thephpleague/oauth2-client.
Installation
Usage
Requesting an access token
There are four different ways to request an access token, and you should be able to determine which to use based on the nature of your application.
Have a read through the Reddit OAuth2 Wiki to find out more.
For web apps, using 'code' and 'state'
You'll receive both code
and state
when redirected from Reddit.
For scripts intended for personal use, using 'username' and 'password'
For installed applications
You should generate and save unique ID on your client. The ID should be unique per-device or per-user of your app. A randomized or pseudo-randomized value is acceptable for generating the ID; however, you should retain and re-use the same device_id when renewing your access token.
For confidential clients (web apps / scripts)
Refreshing an access token
The only way to get a refresh token is by using the state and code redirect flow,
with the duration set as "permanent". The resulting access token will have a valid
refreshToken
property, which you can use to refresh the token.
Note that the refreshed token won't have a refreshToken
field. You should use the
same refresh token every time you refresh the current token, and simply update its
accessToken
and expires
properties.
Using the access token
Reddit requires a few authorization headers when making authenticated API requests.
These can be accessed using $reddit->getHeaders($token)
.
Note: The pending v1.0.0 release of thephpleague/oauth2-client will make this easier by providing an authenticated request object which you can adjust for each request.
Until then, you are advised to use either a dedicated HTTP client or the client used by the provider: