Initializing help system before first use

xpressinsight.scenario.InsightRestClient.__init__

Purpose

Creates a new InsightRestApi instance, which can be used to interact with an Insight v5 server through its REST API. Requests made will be authorized using the user for which the client_id and secret were generated.

The InsightRestApi should be constructed in this way when being used from outside an Insight app; when connecting to the same server currently executing this Python code, use AppInterface.get_rest_client instead.


Synopsis
xpressinsight.scenario.InsightRestClient.__init__(self, insight_url: str, client_id: Optional[str] = None, secret: Optional[str] = None, dmp_iam_url: Optional[str] = None, bearer_token_provider: Optional[Callable[[], BearerToken]] = None, max_retries: int = 5, verify_credentials: bool = True, slow_task_threshold: datetime.timedelta = datetime.timedelta(seconds=120))
Arguments
insight_url 
The URL of the Insight server to access. If copying a URL from the browser, the trailing "/insight" should not be included. For example, "http://localhost:8080/"
client_id 
The client ID value to use to authenticate the session with the Insight server. If not specified, the client ID is read from the system keyring entry "ficoxpress:<insight_url>".
secret 
The secret value to use to authenticate the session with the Insight server. If not specified, the secret is read from the system keyring entry "ficoxpress:<insight_url>". If client_id was specified, keyring will specifically look for an entry with that name and client_id.
dmp_iam_url 
The URL of the DMP IAM endpoint to use to authenticate a session with an Insight component in DMP. This is "https://iam-svc.<domain_name>/registration/rest/client/security/token" where <domain_name> is the domain for the DMP instance you're using; for example "https://iam-svc.mydms.usw2.ficoanalyticcloud.com/registration/rest/client/security/token".
bearer_token_provider 
Function that will return a BearerToken to use to authorize requests to the Insight server. In advanced use cases, a function pointer can be provided as an alternative to specifying the client_id and secret and allowing InsightRestClient to authorize itself.
max_retries 
The maximum number of times to attempt to retry a failed request before giving up. Defaults to 5.
verify_credentials 
Whether to immediately fetch a bearer token and verify that the client_id and secret values are correct. Defaults to True. If set to False, this function will not raise an error if the credentials are invalid; instead, an error is raised from the function that calls out to the Insight REST API.
slow_task_threshold 
Requests and internal tasks taking this time or longer will result in warnings output to the run log. This is a troubleshooting setting that can be used to track if internal xpressinsight operations are being unexpectedly time-consuming.
Return value

This function may raise the following errors:

  ValueError:

If sufficient credentials to authenticate are not passed to this function.

  scenario.AuthenticationError

If authentication with the supplied credentials is unsuccessful.

  scenario.InsightServerError

If there is an issue communicating with the Insight or IAM server.

Example
Example of obtaining an InsightRestClient to communicate with an on-premise Insight server, with the clientID and secret stored in the keyring entry 'ficoxpress:http://localhost:8080/' (recommended pattern on Windows):
>>> client = InsightRestClient(insight_url='http://localhost:8080')			
Example of obtaining an InsightRestClient to communicate with an on-premise Insight server, reading the secret stored in the keyring entry 'ficoxpress:http://localhost:8080/' for the given client ID (recommended on Mac):
>>> MY_CLIENT_ID: str = '<copy client id from Insight UI to here>'
... client = InsightRestClient(insight_url='http://localhost:8080',
...                            client_id=MY_CLIENT_ID)			
Example of obtaining an InsightRestClient to communicate with an on-premise Insight server, passing the credentials as plain text:
>>> MY_CLIENT_ID: str = '<copy client id from Insight UI to here>'
... MY_SECRET: str = '<copy secret from Insight UI to here>'
... client = InsightRestClient(
...     insight_url='http://localhost:8080',
...     client_id=MY_CLIENT_ID, secret=MY_SECRET)			
Example of obtaining an InsightRestClient to communicate with an Insight component on DMP:
>>> MY_CLIENT_ID: str = '<copy client id from DMP UI to here>'
... MY_SECRET: str = '<copy secret from DMP UI to here>'
... IAM_SERVER = 'https://iam-svc.dms.usw2.ficoanalyticcloud.com'
... IAM_URL = f'{IAM_SERVER}/registration/rest/client/security/token'
... client = InsightRestClient(
...     insight_url='https://app.dms.usw2.ficoanalyticcloud.com/16m0jgaeei',
...     dmp_iam_url=IAM_URL,
...     client_id=MY_CLIENT_ID, secret=MY_SECRET)			
Further information
1. The method __init__ is part of the class xpressinsight.scenario.InsightRestClient.
2. When using InsightRestClient from within an Insight scenario to communicate with the same Insight v5 server, it's recommended to use the AppInterface.get_rest_client rather than calling this constructor directly.
3. If client_id or secret are not specified, the Python "keyring" package will be used to read the credentials from a keyring named "ficoxpress:<insight_url>" (where <insight_url> is the URL as passed to this function). When this class is used outside an Insight app (e.g. from a standalone Python script), it's recommended apps follow this pattern to ensure the credentials are passed in securely.
4. On Windows, client_id and secret should be stored in the "generic credentials" area of the Windows credential manager; the secret should not be passed to this function. The client_id can also be omitted, but can be included if required (in which case the stored credentials will only be used if the stored client_id matches the one passed in).
5. On Mac, the "keyring" package cannot read the client_id value from the keychain. You should create an "application password" entry in the keychain with the client_id and secret, but the client_id value should also be passed to this function.
6. If using the client_id and secret from the "Client Apps" page in the DMP user interface, the requests to the Insight server are made as a user named solutionclient. By default, this user can access very little. You might need to add this user to apps, or give it additional authorities, using the Insight administration UI.
7. InsightRestClient can be used as a context manager to ensure rapid cleanup of any resources (HTTP sessions, etc.).
Related topics

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.