AuthBucket\Bundle\OAuth2Bundle\Tests\TestBundle\Controller\DemoController::grantTypeClientCredentialsAction PHP Method

grantTypeClientCredentialsAction() public method

public grantTypeClientCredentialsAction ( Request $request )
$request Symfony\Component\HttpFoundation\Request
    public function grantTypeClientCredentialsAction(Request $request)
    {
        $parameters = ['grant_type' => 'client_credentials', 'scope' => 'demoscope1'];
        $server = ['PHP_AUTH_USER' => 'client_credentials_grant', 'PHP_AUTH_PW' => 'yib6aiFe'];
        $client = new Client($this->get('kernel'));
        $crawler = $client->request('POST', '/api/oauth2/token', $parameters, [], $server);
        $accessTokenResponse = json_decode($client->getResponse()->getContent(), true);
        $accessTokenRequest = get_object_vars($client->getRequest());
        $modelPath = $this->get('router')->generate('demo_resource_type_model', ['access_token' => $accessTokenResponse['access_token']]);
        $debugPath = $this->get('router')->generate('demo_resource_type_debug_endpoint', ['access_token' => $accessTokenResponse['access_token']]);
        $refreshPath = $this->get('router')->generate('demo_grant_type_refresh_token', ['username' => 'client_credentials_grant', 'password' => 'yib6aiFe', 'refresh_token' => $accessTokenResponse['refresh_token']]);
        return $this->render('TestBundle:demo/grant_type:client_credentials.html.twig', ['access_token_response' => $accessTokenResponse, 'access_token_request' => $accessTokenRequest, 'model_path' => $modelPath, 'debug_path' => $debugPath, 'refresh_path' => $refreshPath]);
    }