src/Operation/OAuth/AuthorizationCode.php
public function authenticate($code)
    {
        if (empty($code)) {
            throw new NostoException('Invalid authentication token');
        }

        $request = new HttpRequest();
        $request->setUrl(Nosto::getOAuthBaseUrl() . self::PATH_TOKEN);
        $request->setReplaceParams(
            array(
                '{cid}' => $this->clientId,
                '{sec}' => $this->clientSecret,
                '{uri}' => $this->redirectUrl,
                '{cod}' => $code
            )
        );
        $response = $request->get();
        $result = $response->getJsonResult(true);

        if ($response->getCode() !== 200) {
            throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response);
        }
        if (empty($result['access_token'])) {
            throw new NostoException('No "access_token" returned after authenticating with code');
        }
        if (empty($result['merchant_name'])) {
            throw new NostoException('No "merchant_name" returned after authenticating with code');
        }

        return NostoOAuthToken::create($result);
    }
public function authenticate($code)
    {
        if (empty($code)) {
            throw new NostoException('Invalid authentication token');
        }

        $request = new HttpRequest();
        $request->setUrl(Nosto::getOAuthBaseUrl() . self::PATH_TOKEN);
        $request->setReplaceParams(
            array(
                '{cid}' => $this->clientId,
                '{sec}' => $this->clientSecret,
                '{uri}' => $this->redirectUrl,
                '{cod}' => $code
            )
        );
        $response = $request->get();
        $result = $response->getJsonResult(true);

        if ($response->getCode() !== 200) {
            throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response);
        }
        if (empty($result['access_token'])) {
            throw new NostoException('No "access_token" returned after authenticating with code');
        }
        if (empty($result['merchant_name'])) {
            throw new NostoException('No "merchant_name" returned after authenticating with code');
        }

        return NostoOAuthToken::create($result);
    }
public function authenticate ( $ code ) { if ( empty ( $ code ) ) { throw new NostoException ( 'Invalid authentication token' ) ; } $ request = new HttpRequest ( ) ; $ request -> setUrl ( Nosto :: getOAuthBaseUrl ( ) . self :: PATH_TOKEN ) ; $ request -> setReplaceParams ( array ( '{cid}' => $ this -> clientId , '{sec}' => $ this -> clientSecret , '{uri}' => $ this -> redirectUrl , '{cod}' => $ code ) ) ; $ response = $ request -> get ( ) ; $ result = $ response -> getJsonResult ( true ) ; if ( $ response -> getCode ( ) !== 200 ) { throw ExceptionBuilder :: fromHttpRequestAndResponse ( $ request , $ response ) ; } if ( empty ( $ result [ 'access_token' ] ) ) { throw new NostoException ( 'No "access_token" returned after authenticating with code' ) ; } if ( empty ( $ result [ 'merchant_name' ] ) ) { throw new NostoException ( 'No "merchant_name" returned after authenticating with code' ) ; } return NostoOAuthToken :: create ( $ result ) ; }
Authenticates the application with the given code to receive an access token.

@param string $code code sent by the authorization server to exchange for an access token.
@return NostoOAuthToken
@throws NostoException
Authenticates the application with the given code to receive an access token .