public static function authenticate($account = null)
    {
        $configs = (new ConfigurationRepository)->useAccount($account);
        $key = $configs->getAccountKey('key');
        $secret = $configs->getAccountKey('secret');
        $cacheKey = self::AC_TOKEN . "{$key}{$secret}";

        if ($token = Core::instance()->cache()->get($cacheKey)) {
            return $token;
        }

        try {
            $response = self::makeRequest($key, $secret, $account);
            $body = json_decode($response->getBody());
            self::saveCredentials($cacheKey, $body);

            return $body->access_token;
        } catch (RequestException $exception) {
            $message = $exception->getResponse() ?
               $exception->getResponse()->getReasonPhrase() :
               $exception->getMessage();

            throw self::generateException($message);
        }
    }
public static function authenticate($account = null)
    {
        $configs = (new ConfigurationRepository)->useAccount($account);
        $key = $configs->getAccountKey('key');
        $secret = $configs->getAccountKey('secret');
        $cacheKey = self::AC_TOKEN . "{$key}{$secret}";

        if ($token = Core::instance()->cache()->get($cacheKey)) {
            return $token;
        }

        try {
            $response = self::makeRequest($key, $secret, $account);
            $body = json_decode($response->getBody());
            self::saveCredentials($cacheKey, $body);

            return $body->access_token;
        } catch (RequestException $exception) {
            $message = $exception->getResponse() ?
               $exception->getResponse()->getReasonPhrase() :
               $exception->getMessage();

            throw self::generateException($message);
        }
    }
public static function authenticate ( $ account = null ) { $ configs = ( new ConfigurationRepository ) -> useAccount ( $ account ) ; $ key = $ configs -> getAccountKey ( 'key' ) ; $ secret = $ configs -> getAccountKey ( 'secret' ) ; $ cacheKey = self :: AC_TOKEN . "{$key}{$secret}" ; if ( $ token = Core :: instance ( ) -> cache ( ) -> get ( $ cacheKey ) ) { return $ token ; } try { $ response = self :: makeRequest ( $ key , $ secret , $ account ) ; $ body = json_decode ( $ response -> getBody ( ) ) ; self :: saveCredentials ( $ cacheKey , $ body ) ; return $ body -> access_token ; } catch ( RequestException $ exception ) { $ message = $ exception -> getResponse ( ) ? $ exception -> getResponse ( ) -> getReasonPhrase ( ) : $ exception -> getMessage ( ) ; throw self :: generateException ( $ message ) ; } }
Get the access token required to transact.

@param string $account

@return mixed

@throws ConfigurationException
Get the access token required to transact .