/** * @param $username * @param $password * @param bool $secure * @param bool $pullProfile * @return Account * @throws AccountCredentialsError */ public static function authorize($username, $password, $secure = true, $pullProfile = true) { if (empty($username) || empty($password)) { throw new AccountCredentialsError("Username and Password must be defined"); } /** @var Account $account */ $account = new static(); $account->setUsername($username); $account->setPassword($password); $account->setSecure($secure); $token = Request::token($account->getCredential(), $account->getSecure()); $account->setToken($token)->setIsAuthorized(true); if ($pullProfile) { $account->compose(); } return $account; }