Download the PHP package nyan02/kphp_oauth2_client without Composer
On this page you can find all versions of the php package nyan02/kphp_oauth2_client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nyan02/kphp_oauth2_client
More information about nyan02/kphp_oauth2_client
Files in nyan02/kphp_oauth2_client
Package kphp_oauth2_client
Short Description OAuth 2.0 Client Library for KPHP
License MIT
Informations about the package kphp_oauth2_client
This package provides OAuth 2.0 client support for the KPHP
Installation
To install, use composer:
Usage
This package implements Generic Provider. However, it is better to use specific providers. There are currently 2 supported providers:
- google (nyan02/kphp_oauth2_google)
- keycloak (nyan02/kphp_oauth2_keycloak)
This package implements Abstract Provider, that can be used to create new packages for other providers. Generally, to write a new provider you need to implement a new Provider/YourProvider.php by inheriting from Abstract provider, a Provider/YourResourceOwner.php by implementing ResourceOwnerInterface and a new AuthorizationParameters/YourAuthorizationParameters by implementing AuthorizationParametersInterface
You can find simple example on how to implement a new provider in source code for nyan02/kphp_oauth2_google. Usually you won't need to change much, just to account for specifics of a certain provider.
This framework allows to use the same flow for all the providers that inherit from this package. The only step that differs between providers is configuring a provider.
Authorization Code Flow
After configuring provider we want to get Authorization Code. We use method getAuthorizationParameters() to get parameters from the provider including permission scopes and other info needed for generating AuthorizationUrl.
Next we generate AuthorizationUrl using method getAuthorizationUrl($params) and passing parameters we've got before. Now that we have the Url we can redirect the user to Authorization page of provider.
Once we've got Authorization Code we create a placeholder class for it
And pass it to getAccessToken method together with the code we've got.
Now we have the Access Token to Resource.