public function auth($user = null, $password = null)
    {
        if ($this->token) return $this;

        if (is_null($user) || is_null($password))
        {
            throw new MontageAuthException('Must provide a username and password.');
        }

        try {
            $response = $this->request('post', $this->url('auth'), [
                'form_params' => [
                    'username' => $user,
                    'password' => $password
                ]
            ]);

            $this->token = $response->data->token;

            return $this;
        } catch (ClientException $e) {
            throw new MontageAuthException('Could not authenticate with Montage.');
        }
    }
public function auth($user = null, $password = null)
    {
        if ($this->token) return $this;

        if (is_null($user) || is_null($password))
        {
            throw new MontageAuthException('Must provide a username and password.');
        }

        try {
            $response = $this->request('post', $this->url('auth'), [
                'form_params' => [
                    'username' => $user,
                    'password' => $password
                ]
            ]);

            $this->token = $response->data->token;

            return $this;
        } catch (ClientException $e) {
            throw new MontageAuthException('Could not authenticate with Montage.');
        }
    }
public function auth ( $ user = null , $ password = null ) { if ( $ this -> token ) return $ this ; if ( is_null ( $ user ) || is_null ( $ password ) ) { throw new MontageAuthException ( 'Must provide a username and password.' ) ; } try { $ response = $ this -> request ( 'post' , $ this -> url ( 'auth' ) , [ 'form_params' => [ 'username' => $ user , 'password' => $ password ] ] ) ; $ this -> token = $ response -> data -> token ; return $ this ; } catch ( ClientException $ e ) { throw new MontageAuthException ( 'Could not authenticate with Montage.' ) ; } }
Authenticate with Montage and set the local token.

@param null $user
@param null $password
@return $this
@throws MontageAuthException
Authenticate with Montage and set the local token .