src/Token.php
public function createApplicationToken($application, $privateKey)
    {
        $tokenRequest = $this->getTokenizer()->signTokenRequest(
            $this->getTokenizer()->createApplicationTokenRequest(
                $application
            ),
            $privateKey
        );

        $request = (new RequestDescriptor())
            ->setUrl($this->buildUrl('/api/token'))
            ->setMethod('POST');
        $request->setBodyParams([
            'token-request' => json_encode($tokenRequest->toArray())
        ]);

        try {
            return json_decode($this->send($request)->getBody(), true);
        } catch (\Exception $e) {
            $previous = $e->getPrevious();

            if ($previous instanceof BadResponseException) {
                $error = json_decode($previous->getResponse()->getBody(true), true);

                throw new TokenException($error['error'], $error['code'], $previous);
            }

            throw new TokenException($e->getMessage(), $e->getCode(), $e->getPrevious());
        }
    }
public function createApplicationToken($application, $privateKey)
    {
        $tokenRequest = $this->getTokenizer()->signTokenRequest(
            $this->getTokenizer()->createApplicationTokenRequest(
                $application
            ),
            $privateKey
        );

        $request = (new RequestDescriptor())
            ->setUrl($this->buildUrl('/api/token'))
            ->setMethod('POST');
        $request->setBodyParams([
            'token-request' => json_encode($tokenRequest->toArray())
        ]);

        try {
            return json_decode($this->send($request)->getBody(), true);
        } catch (\Exception $e) {
            $previous = $e->getPrevious();

            if ($previous instanceof BadResponseException) {
                $error = json_decode($previous->getResponse()->getBody(true), true);

                throw new TokenException($error['error'], $error['code'], $previous);
            }

            throw new TokenException($e->getMessage(), $e->getCode(), $e->getPrevious());
        }
    }
public function createApplicationToken ( $ application , $ privateKey ) { $ tokenRequest = $ this -> getTokenizer ( ) -> signTokenRequest ( $ this -> getTokenizer ( ) -> createApplicationTokenRequest ( $ application ) , $ privateKey ) ; $ request = ( new RequestDescriptor ( ) ) -> setUrl ( $ this -> buildUrl ( '/api/token' ) ) -> setMethod ( 'POST' ) ; $ request -> setBodyParams ( [ 'token-request' => json_encode ( $ tokenRequest -> toArray ( ) ) ] ) ; try { return json_decode ( $ this -> send ( $ request ) -> getBody ( ) , true ) ; } catch ( \ Exception $ e ) { $ previous = $ e -> getPrevious ( ) ; if ( $ previous instanceof BadResponseException ) { $ error = json_decode ( $ previous -> getResponse ( ) -> getBody ( true ) , true ) ; throw new TokenException ( $ error [ 'error' ] , $ error [ 'code' ] , $ previous ) ; } throw new TokenException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } }
Create an application token

@param string          $application
@param resource|string $privateKey

@return string
Create an application token