I have some code working great via a Notebook, but I want to move it to a server where I can run it as daemon. The authentication is failing when I run it on the server.
I suspect the problem is with the Scopes - User impersonation might work in the browser where I’m already logged in to the right project. What scope should I use instead when I’m calling directly from Python?
Also tried
myscope = '[f"https://westeurope-1.cognitedata.com/.default"]'
as suggested in the documentation
oauthlib.oauth2.rfc6749.errors.AccessDeniedError: (access_denied) Unauthorized
from cognite.client import CogniteClient, ClientConfig
from cognite.client.credentials import OAuthClientCredentials
from cognite.client.data_classes import TimeSeries
host = "https://westeurope-1.cognitedata.com"
myproject = "rok-buandcollaborators-53"
clientid = "realStuffWasHere"
secret = "secretsecretsecretsecretsecretsecret"
#myscope = "https://westeurope-1.cognitedata.com/.default"
myscope='["IDENTITY", "user_impersonation"]'
token="https://datamosaix-prod.us.auth0.com/oauth/token"
dataset = 8883655420989208 #chemdemo dataset
#creds = OAuthClientCredentials(token_url=token,client_id=clientid, client_secret=secret, scopes=myscope)
#cnf = ClientConfig(client_name="SJC_Raspi3b", base_url=host, project=myproject, credentials=creds)
creds = OAuthClientCredentials(
token_url=token, # https://datamosaix-qa.us.auth0.com/oauth/token
client_id=clientid,
client_secret=secret,
scopes=["IDENTITY", "user_impersonation"]
)
cnf = ClientConfig(
client_name="SJC_Raspi3b",
project=myproject,
credentials=creds,
base_url=host
)
cdf_client = CogniteClient(cnf)
ts_list = cdf_client.time_series.list() #debugging test for creds. not needed for real
print (ts_list)