def auth(self, auth_type, auth_key, project_id=None):
        """Creates authenticated client.

        Parameters:

        * `auth_type` - Authentication type. Use `session` for auth
          by session key. Use `token` for auth by token.
        * `auth_key` - Authentication `session key` or `token`.
        * `project_id` - Project identifier. Must be provided for
          `token` authentication. Default is `None`.

        Returns:

        * Instance of [SessionAuthClient](#sessionauthclient) if
          `auth_type` is `session`.
        * Instance of [ProjectClient](#projectclient) if
          `auth_type` is `token`

        Raises:

        * ValueError: if `project_id` parameter was not provided

        Examples:

        For auth with `session` you should obtain session key by
        [Client.user.login](#clientuserlogin) providing
        your account's email and password:

        ```python
        client = Client(host='deform.io')
        session_client = client.auth(
            'session',
            client.user.login(
                email='email@example.com',
                password='password'
            ),
        )
        print session_client
        <pydeform.client.SessionAuthClient object at 0x10c585650>
        ```

        Authentication with `token` example:

        ```python
        client = Client(host='deform.io')
        token_client = client.auth(
          'token',
          auth_key='token-value',
          project_id='some-project',
        )
        print token_client
        <pydeform.client.ProjectClient object at 0x11c585650>
        ```

        """
        if auth_type == 'session':
            return SessionAuthClient(
                auth_header=get_session_http_auth_header(auth_key),
                host=self.host,
                port=self.port,
                secure=self.secure,
                requests_session=self.requests_session,
                request_defaults=self.request_defaults,
                api_base_path=self.api_base_path,
            )
        elif auth_type == 'token':
            if not project_id:
                msg = 'You should provide project_id for token authentication'
                raise ValueError(msg)
            return ProjectClient(
                base_uri=get_base_uri(
                    project=project_id,
                    host=self.host,
                    port=self.port,
                    secure=self.secure,
                    api_base_path=self.api_base_path
                ),
                auth_header=get_token_http_auth_header(auth_key),
                requests_session=self.requests_session,
                request_defaults=self.request_defaults,
            )
Creates authenticated client.

        Parameters:

        * `auth_type` - Authentication type. Use `session` for auth
          by session key. Use `token` for auth by token.
        * `auth_key` - Authentication `session key` or `token`.
        * `project_id` - Project identifier. Must be provided for
          `token` authentication. Default is `None`.

        Returns:

        * Instance of [SessionAuthClient](#sessionauthclient) if
          `auth_type` is `session`.
        * Instance of [ProjectClient](#projectclient) if
          `auth_type` is `token`

        Raises:

        * ValueError: if `project_id` parameter was not provided

        Examples:

        For auth with `session` you should obtain session key by
        [Client.user.login](#clientuserlogin) providing
        your account's email and password:

        ```python
        client = Client(host='deform.io')
        session_client = client.auth(
            'session',
            client.user.login(
                email='email@example.com',
                password='password'
            ),
        )
        print session_client
        <pydeform.client.SessionAuthClient object at 0x10c585650>
        ```

        Authentication with `token` example:

        ```python
        client = Client(host='deform.io')
        token_client = client.auth(
          'token',
          auth_key='token-value',
          project_id='some-project',
        )
        print token_client
        <pydeform.client.ProjectClient object at 0x11c585650>
        ```