Download the PHP package ely/oauth2-client without Composer
On this page you can find all versions of the php package ely/oauth2-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ely/oauth2-client
More information about ely/oauth2-client
Files in ely/oauth2-client
Package oauth2-client
Short Description Ely.by provider for league/oauth2-client
License MIT
Homepage https://github.com/elyby/league-oauth2-ely
Informations about the package oauth2-client
Ely.by Provider for OAuth 2.0 Client
This package provides Ely.by OAuth 2.0 support for the PHP League's OAuth 2.0 Client.
Installation
To install, use composer:
Usage
Usage is the same as The League's OAuth client, using \Ely\OAuth2\Client\Provider
as the provider. You can find
more information in League repository README.
You can get your own clientId
and clientSecret
at Ely.by Account OAuth2 registration page.
We suggest to put this provider object into service locator for access it at any time or mock for testing.
In code below we think, that $provider
contains our provider object.
Authorization Code Flow
First of all, you must generate redirect user to route, which will set state session value and redirect user to Ely.by authorization page. This can be done by such code, placed into controller:
Note, that getAuthorizationUrl()
takes as argument array of overriding parameters. For example, if you want request
additional scopes and change app description, then you must pass scope
and description
keys with needed values:
After user finish authentication and authorization on Ely.by Account site, he will be redirected back, on redirectUri
,
that you specified in Provider configuration. Inside redirectUri handler you must check for errors and state matches.
If all checks passed normal, then try to exchange received auth_code
to access_token
. This can be done by code
like below:
Refreshing a Token
Refresh tokens are only provided to applications which request offline access. You can specify offline access by
setting the scope
option on authorization url generating:
It is important to note that the refresh token is only returned on the first request after this it will be null. You should securely store the refresh token when it is returned:
Now you have everything you need to refresh an access token using a refresh token:
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
This package was designed and developed within the Ely.by project team. We also thank all the contributors for their help.
License
The MIT License (MIT). Please see License File for more information.