cognite-sdk-python
cognite-sdk-python copied to clipboard
Add support for credential providers with the ability to refresh tokens in Pyodide
The latest release of the Cognite Python SDK adds support for Pyodide and it works great if the client
is instantiated with a Token
generated somewhere else. Any of the current credential providers that rely on msal
are not working in Pyodide and some work might need to be done to patch msal
to work without regular requests
.
Adding to the issue: For client credentials (OAuthClientCredentials
), which doesn't use the msal
package, the error is different:
JsException:
NetworkError:
Failed to execute 'send' on 'XMLHttpRequest':
Failed to load 'https://login.microsoftonline.com/0d75f6b8-c6b9-4e84-baca-503e08aa7e4a/oauth2/v2.0/token'.
Adding another similar-in-nature issue:
Calling e.g. client.iam.service_accounts.list()
which for many projects have been deactivated and returning 404
, will raise a pyodide.JsException
instead of subclass of CogniteException
like CogniteAPIError
. Needs to add or patch a check for it.
Found by @ks93
https://pyodide.org/en/0.19.1/usage/api/python-api.html#pyodide.JsException