-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun-example.php
36 lines (29 loc) · 1.25 KB
/
run-example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
use BrenoRoosevelt\OAuth2\Client\Example\AuthorizationCodeFlow;
use BrenoRoosevelt\OAuth2\Client\Example\StateStorage;
use BrenoRoosevelt\OAuth2\Client\GovBr;
use Laminas\Diactoros\ServerRequestFactory;
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Middlewares\Utils\CallableHandler;
use Middlewares\Utils\Dispatcher;
use Middlewares\Whoops;
require __DIR__ . '/vendor/autoload.php';
// Para executar siga o roteiro em "staging.md"
// Provider GovBr (homologacao)
$govBr = GovBr::staging([
'clientId' => 'XXXXXXXX', // Client ID fornecido pelo GovBr
'clientSecret' => 'YYYYYYYY', // Senha fornecida pelo provedor GovBr
'redirectUri' => "https://seu-app-dominio.com.br/seu-oauth-login", // Url de redirecionamento cadastrada no GovBr
'redirectUriLogout' => "https://seu-app-dominio.com.br/seu-logout" // Url de redirecionamento logout
]);
$authorizationCodeFlow = new AuthorizationCodeFlow($govBr, new StateStorage());
// Despacha a requisição http (seu framework faz isso)
$response =
Dispatcher::run([
new Whoops(),
new CallableHandler($authorizationCodeFlow)
],
ServerRequestFactory::fromGlobals()
);
(new SapiEmitter())->emit($response);