def obtain_token(self, config=None):
        """Obtain the token to access to QX Platform.

        Raises:
            CredentialsError: when token is invalid or the user has not
                accepted the license.
            ApiError: when the response from the server couldn't be parsed.
        """
        client_application = CLIENT_APPLICATION
        if self.config and ("client_application" in self.config):
            client_application += ':' + self.config["client_application"]
        headers = {'x-qx-client-application': client_application}

        if self.token_unique:
            try:
                response = requests.post(str(self.config.get('url') +
                                             "/users/loginWithToken"),
                                         data={'apiToken': self.token_unique},
                                         verify=self.verify,
                                         headers=headers,
                                         **self.extra_args)
            except requests.RequestException as e:
                raise ApiError('error during login: %s' % str(e))
        elif config and ("email" in config) and ("password" in config):
            email = config.get('email', None)
            password = config.get('password', None)
            credentials = {
                'email': email,
                'password': password
            }
            try:
                response = requests.post(str(self.config.get('url') +
                                             "/users/login"),
                                         data=credentials,
                                         verify=self.verify,
                                         headers=headers,
                                         **self.extra_args)
            except requests.RequestException as e:
                raise ApiError('error during login: %s' % str(e))
        else:
            raise CredentialsError('invalid token')

        if response.status_code == 401:
            error_message = None
            try:
                # For 401: ACCEPT_LICENSE_REQUIRED, a detailed message is
                # present in the response and passed to the exception.
                error_message = response.json()['error']['message']
            except:
                pass

            if error_message:
                raise CredentialsError('error during login: %s' % error_message)
            else:
                raise CredentialsError('invalid token')
        try:
            response.raise_for_status()
            self.data_credentials = response.json()
        except (requests.HTTPError, ValueError) as e:
            raise ApiError('error during login: %s' % str(e))

        if self.get_token() is None:
            raise CredentialsError('invalid token')
Obtain the token to access to QX Platform.

        Raises:
            CredentialsError: when token is invalid or the user has not
                accepted the license.
            ApiError: when the response from the server couldn't be parsed.