PHP code example of fathershawn / oauth2-formassembly
1. Go to this page and download the library: Download fathershawn/oauth2-formassembly library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fathershawn / oauth2-formassembly example snippets
use Fathershawn\OAuth2\Client\Provider\FormAssembly as OauthProvider;
$provider = new OauthProvider([
'clientId' => 'your-client-id',
'clientSecret' => 'your-client-secret',
'redirectUri' => 'url-to-capture-the-code',
'baseUrl' => 'url-to-formassembly-instance',
]);
$url = $provider->getAuthorizationUrl();
// Redirect the user to $url.
use Fathershawn\OAuth2\Client\Provider\FormAssembly as OauthProvider;
// Capture the code with your framework or from $_GET['code'].
$code = $_GET['code'];
$provider = new OauthProvider([
'clientId' => 'your-client-id',
'clientSecret' => 'your-client-secret',
'redirectUri' => 'url-to-capture-the-code',
'baseUrl' => 'url-to-formassembly-instance',
]);
try {
$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $code,
]);
// Store $accessToken as appropriate for re-use.
} catch (Exception $e) {
// Log the Exception?
throw $e;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.