aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/api/oauth2/token.php
blob: 0ae7ffbd2d87fe3bf73155e9568421495bc5c5c4 (plain)
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
<?php
require_once __DIR__ . '/oauth2_controller.php';

class Api_Oauth2_TokenController extends OAuth2Controller
{
    public function before_filter(&$action, &$args)
    {
        parent::before_filter($action, $args);

        if ('index' !== $action) {
            throw new Trails_Exception(404);
        }

        if (!Request::isPost()) {
            throw new Trails_Exception(405);
        }

        $action = 'issue_token';
    }

    public function issue_token_action(): void
    {
        $psrRequest = $this->getPsrRequest();
        $psrResponse = $this->getPsrResponse();
        $response = $this->server->respondToAccessTokenRequest($psrRequest, $psrResponse);

        $this->renderPsrResponse($response);
    }
}