GetPublicApiClientUsingApiKey
get_public_api_client_using_api_key(app_name_header, on_behalf_of_header, client_type_header, api_key_header)
Expand source code
get_public_api_client_using_api_key(app_name_header, on_behalf_of_header, client_type_header, api_key_header):"""Description-----------Method 2, To get the client object of QDC Api using api key.Args----app_name_header: Name of the Client.on_behalf_of_header: Name of the user who is initiating the request.client_type_header: Client code type connecting to QDC Api.api_key_header: Get the api key from the QDC UI -> Users -> settings -> API KeysReturns-------object: Authenticated client object.None: In case of an failure.Usages------# qdc_api is the name of the module# Please get the api key from the QDC UI -> Users -> settings -> API Keysapp_name = "ai hub"client_type = "Python"on_behalf_of_header = "user"api_key = ""public_api_client = qdc_api.get_public_api_client_using_api_key(app_name, on_behalf_of_header, client_type, api_key)"""# Below headers are mandatory for now, please set X-QCOM-OnBehalfOf accordinglyqdc_headers = {"Authorization": api_key_header,"X-QCOM-TokenType": "apikey","X-QCOM-AppName": app_name_header,"X-QCOM-ClientType": client_type_header,"X-QCOM-OnBehalfOf": on_behalf_of_header}# Create the client using access tokenreturn Client(base_url=API_BASE_URL, headers=qdc_headers)
Description
Method 2, To get the client object of QDC Api using api key.
Arguments
app_name_header
: Name of the Client.on_behalf_of_header
: Name of the user who is initiating the request.client_type_header
: Client code type connecting to QDC Api.api_key_header
: Get the api key from the QDC UI -> Users -> settings -> API Keys
Returns
object
: Authenticated client object.None
: In case of an failure.
Usages
- qdc_api is the name of the module
- Please get the api key from the QDC UI -> Users -> settings -> API Keys
app_name = "ai hub"client_type = "Python"on_behalf_of_header = "user"api_key = ""public_api_client = qdc_api.get_public_api_client_using_api_key(app_name, on_behalf_of_header, client_type, api_key)