AuthBucket\OAuth2\Tests\TestBundle\Controller\DemoController::grantTypeAuthorizationCodeAction PHP Method

grantTypeAuthorizationCodeAction() public method

public grantTypeAuthorizationCodeAction ( Request $request, Silex\Application $app )
$request Symfony\Component\HttpFoundation\Request
$app Silex\Application
    public function grantTypeAuthorizationCodeAction(Request $request, Application $app)
    {
        $parameters = ['grant_type' => 'authorization_code', 'code' => $request->query->get('code'), 'redirect_uri' => $request->getUriForPath('/demo/response_type/code'), 'client_id' => 'authorization_code_grant', 'client_secret' => 'uoce8AeP'];
        $server = [];
        $client = new Client($app);
        $crawler = $client->request('POST', '/api/oauth2/token', $parameters, [], $server);
        $accessTokenResponse = json_decode($client->getResponse()->getContent(), true);
        $accessTokenRequest = get_object_vars($client->getRequest());
        $modelPath = $app['url_generator']->generate('demo_resource_type_model', ['access_token' => $accessTokenResponse['access_token']]);
        $debugPath = $app['url_generator']->generate('demo_resource_type_debug_endpoint', ['access_token' => $accessTokenResponse['access_token']]);
        $refreshPath = $app['url_generator']->generate('demo_grant_type_refresh_token', ['username' => 'authorization_code_grant', 'password' => 'uoce8AeP', 'refresh_token' => $accessTokenResponse['refresh_token']]);
        return $app['twig']->render('demo/grant_type/authorization_code.html.twig', ['access_token_response' => $accessTokenResponse, 'access_token_request' => $accessTokenRequest, 'model_path' => $modelPath, 'debug_path' => $debugPath, 'refresh_path' => $refreshPath]);
    }