ibm_aigov_facts_client.supporting_classes.cp4d_authenticator module

class CP4DAuthenticator(username: str, url: str, *, password: str = None, apikey: str = None, disable_ssl_verification: bool = False, headers: Dict[str, str] | None = None, proxies: Dict[str, str] | None = None, bedrock_url: str = None)

Bases: CloudPakForDataAuthenticator

The CloudPakForDataAuthenticator utilizes a username and password pair to obtain a suitable bearer token, and adds it requests. The bearer token will be sent as an Authorization header in the form:

Authorization: Bearer <bearer-token>

Args:

username: The username used to obtain a bearer token. url: The URL representing the Cloud Pak for Data token service endpoint.

Keyword Args:

password: The password used to obtain a bearer token. apikey: Platform api key disable_ssl_verification: A flag that indicates whether verification of the server’s SSL

certificate should be disabled or not. Defaults to False.

headers: Default headers to be sent with every CP4D token request. Defaults to None. proxies: Dictionary for mapping request protocol to proxy URL. proxies.http (optional): The proxy endpoint to use for HTTP requests. proxies.https (optional): The proxy endpoint to use for HTTPS requests.

Attributes:

token_manager (CP4DTokenManager): Retrives and manages CP4D tokens from the endpoint specified by the url.

Raises:

ValueError: The username, password, and/or url are not valid for CP4D token requests.

get_cp4d_auth_token() None

Adds CP4D authentication information to the request. The CP4D bearer token will be added to the request’s headers in the form:

Authorization: Bearer <bearer-token>

Args:

req: The request to add CP4D authentication information too. Must contain a key to a dictionary called headers.