Impact 2024: The Industrial Data and AI Conference for and by Users | Nominate Speakers Now for a Ch...
Leaving this as a how to guide for others that struggled like I have been.I am in the position where I want to use the publicdata with Python using a ClientSecret. I did not want to use interactive logons or the device flow. I struggled to understand exactly which bits of the SDK and which values to use where.Working Python code that will run in a Django management command is below but it should be trivial to change it for other apps.import asyncioimport atexitimport datetimeimport osimport timefrom channels.layers import get_channel_layerfrom cognite.client import ClientConfig, CogniteClientfrom cognite.client.credentials import OAuthClientCredentials, Tokenfrom django.core.management.base import BaseCommandfrom msal import PublicClientApplication, SerializableTokenCache# Contact Project Administrator to get theseTENANT_ID = "48d5043c-cf70-4c49-881c-c638f5796997" # use Cognite Client details from https://hub.cognite.com/open-industrial-data-211/openid-connect-on-open-industrial-data-9
I have got postman connected to the publicdata project using the details below:Environmenttenant-id: 48d5043c-cf70-4c49-881c-c638f5796997 baseUrl: https://api.cognitedata.com project: publicdata cluster: apiAuth token:callbackUrl: https://postman.cogniteapp.com/loggedin authUrl: https://login.microsoftonline.com/{{tenant-id}}/oauth2/v2.0/authorize clientId: https://postman.cogniteapp.com Scope: https://{{cluster}}.cognitedata.com/.defaultI sign in with the credentials I used to sign up in the Cognite Academy, which I understand means they are added to the Azure AD for the publicdata project.I can access some of the api endpoints via Postman so the authentication is working but I get a 403 unauthorised when I try to list all Assets. Am I meant to be able to see the assets in Postman with this setup? Thanks in advance, Andy
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.