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

grantTypeClientCredentialsAction() public method

public grantTypeClientCredentialsAction ( Request $request, Silex\Application $app )
$request Symfony\Component\HttpFoundation\Request
$app Silex\Application
    public function grantTypeClientCredentialsAction(Request $request, Application $app)
    {
        $parameters = ['grant_type' => 'client_credentials', 'scope' => 'demoscope1'];
        $server = ['PHP_AUTH_USER' => 'client_credentials_grant', 'PHP_AUTH_PW' => 'yib6aiFe'];
        $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' => 'client_credentials_grant', 'password' => 'yib6aiFe', 'refresh_token' => $accessTokenResponse['refresh_token']]);
        return $app['twig']->render('demo/grant_type/client_credentials.html.twig', ['access_token_response' => $accessTokenResponse, 'access_token_request' => $accessTokenRequest, 'model_path' => $modelPath, 'debug_path' => $debugPath, 'refresh_path' => $refreshPath]);
    }