tayganr / purviewcli

Microsoft Purview CLI
https://aka.ms/purviewcli
MIT License
48 stars 27 forks source link

SPN authentication error #21

Closed rebremer closed 1 year ago

rebremer commented 2 years ago

When I use

%env AZURE_CLIENT_ID=YOUR_CLIENT_ID %env AZURE_TENANT_ID=YOUR_TENANT_ID %env AZURE_CLIENT_SECRET=YOUR_CLIENT_SECRET

and then run:

glossary = !pv glossary read

I get the following error, both in Databricks and in my local environment in ipynb:

['Traceback (most recent call last):', ' File "C:\Python38\lib\runpy.py", line 194, in _run_module_as_main', ' return _run_code(code, main_globals, None,', ' File "C:\Python38\lib\runpy.py", line 87, in _run_code', ' exec(code, run_globals)', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\Scripts\pv.exe\main.py", line 7, in ', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\purviewcli\cli\cli.py", line 77, in main', ' data = funcObj(command_args)', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\purviewcli\client\endpoint.py", line 42, in wrapper', ' data = get_data(http_dict)', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\purviewcli\client\endpoint.py", line 18, in get_data', " client.set_token(http_dict['app'])", ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\purviewcli\client\client.py", line 39, in set_token', ' credential = DefaultAzureCredential(exclude_shared_token_cache_credential=True)', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\azure\identity\_credentials\default.py", line 121, in init', ' credentials.append(EnvironmentCredential(authority=authority, **kwargs))', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 62, in init', ' self._credential = ClientSecretCredential(', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\azure\identity\_credentials\client_secret.py", line 40, in init', ' super(ClientSecretCredential, self).init(', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\azure\identity\_internal\msal_credentials.py", line 33, in init', ' validate_tenant_id(self._tenant_id)', ' File "c:\Users\rebremer\gitpublic\azure-functions-datalake-recovery-pitr\.venv\lib\site-packages\azure\identity\_internal\init.py", line 61, in validate_tenant_id', ' raise ValueError(', 'ValueError: Invalid tenant id provided. You can locate your tenant id by following the instructions here: https://docs.microsoft.com/partner-center/find-ids-and-domain-names']

tayganr commented 2 years ago

Hi @rebremer, the error seems to relate to the lack of a specified Tenant ID.

ValueError: Invalid tenant id provided.

If using the environment variable method to provide purviewcli an identity, the below variables (including AZURE_TENANT_ID) need to be provided.

rebremer commented 2 years ago

Hi @tayganr ,

Thx for your response, I used "" when I set the environment variables. After I removed the "", it went fine. Maybe something to document that no quotations shall be used.

tayganr commented 1 year ago

Thanks @rebremer. Regarding the syntax for setting the environment variables, it will vary depending on the IDE. Examples below from the purviewcli help prompt. image