src/Controller/Access.php
public function exchangeAction(Request $request) {
        try {
            $authCode = $this->getAuthCode($request);
            $this->info('> Exchange request', ['method' => $request->getMethod(), 'auth_code' => $authCode]);

            $clientSecret = $this->getClientSecret($request);
            $credentials = $this->accessProvider->exchange($authCode, $clientSecret);
            $response = new JsonResponse([
                'access_code' => $credentials->getAccessCode(),
                'refresh_code' => $credentials->getRefreshCode(),
                'lifetime' => $credentials->getLifetime()
            ]);
        } catch (SoauthException $e) {
            $data = [];

            if($e instanceof BadDataException) {
                $data['errors'] = $e->getErrors();
            }

            $response = new JsonResponse($data, Response::HTTP_BAD_REQUEST);
        }

        $this->info('< Response', ['status_code' => $response->getStatusCode()]);

        return $response;
    }
public function exchangeAction(Request $request) {
        try {
            $authCode = $this->getAuthCode($request);
            $this->info('> Exchange request', ['method' => $request->getMethod(), 'auth_code' => $authCode]);

            $clientSecret = $this->getClientSecret($request);
            $credentials = $this->accessProvider->exchange($authCode, $clientSecret);
            $response = new JsonResponse([
                'access_code' => $credentials->getAccessCode(),
                'refresh_code' => $credentials->getRefreshCode(),
                'lifetime' => $credentials->getLifetime()
            ]);
        } catch (SoauthException $e) {
            $data = [];

            if($e instanceof BadDataException) {
                $data['errors'] = $e->getErrors();
            }

            $response = new JsonResponse($data, Response::HTTP_BAD_REQUEST);
        }

        $this->info('< Response', ['status_code' => $response->getStatusCode()]);

        return $response;
    }
public function exchangeAction ( Request $ request ) { try { $ authCode = $ this -> getAuthCode ( $ request ) ; $ this -> info ( '> Exchange request' , [ 'method' => $ request -> getMethod ( ) , 'auth_code' => $ authCode ] ) ; $ clientSecret = $ this -> getClientSecret ( $ request ) ; $ credentials = $ this -> accessProvider -> exchange ( $ authCode , $ clientSecret ) ; $ response = new JsonResponse ( [ 'access_code' => $ credentials -> getAccessCode ( ) , 'refresh_code' => $ credentials -> getRefreshCode ( ) , 'lifetime' => $ credentials -> getLifetime ( ) ] ) ; } catch ( SoauthException $ e ) { $ data = [ ] ; if ( $ e instanceof BadDataException ) { $ data [ 'errors' ] = $ e -> getErrors ( ) ; } $ response = new JsonResponse ( $ data , Response :: HTTP_BAD_REQUEST ) ; } $ this -> info ( '< Response' , [ 'status_code' => $ response -> getStatusCode ( ) ] ) ; return $ response ; }
exchange auth for an access code
@param $request
@return string|Response
exchange auth for an access code