PHP code example of halloverden / symfony-oidc-client-bundle
1. Go to this page and download the library: Download halloverden/symfony-oidc-client-bundle 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/ */
halloverden / symfony-oidc-client-bundle example snippets
namespace App\Controller;
use HalloVerden\Oidc\ClientBundle\Interfaces\OauthAuthorizeServiceInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class AuthorizeController
*
* @package App\Controller
*
* @Route("/authorize", methods={"GET"}, name="authorize")
*/
class AuthorizeController {
/**
* @param Request $request
* @param OauthAuthorizeServiceInterface $oauthAuthorizeService
*
* @return RedirectResponse
*/
public function __invoke(Request $request, OauthAuthorizeServiceInterface $oauthAuthorizeService): RedirectResponse {
return $oauthAuthorizeService->handleAuthorize($request);
}
}
namespace App\Controller;
use HalloVerden\Oidc\ClientBundle\Interfaces\OauthAuthorizeServiceInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class HandleAuthCodeController
*
* @package App\Controller
*
* @Route("/handle", methods={"GET"}, name="authcodehandle")
*/
class HandleAuthCodeController {
/**
* @param Request $request
* @param OauthAuthorizeServiceInterface $oauthAuthorizeService
*
* @return RedirectResponse
*/
public function __invoke(Request $request, OauthAuthorizeServiceInterface $oauthAuthorizeService): RedirectResponse {
return $oauthAuthorizeService->handleAuthCode($request);
}
}
$openIdProviderService->getTokenResponse(new ClientCredentialsGrant())->getAccessToken();