cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
188 stars 107 forks source link

TM1py SSO problem #622

Closed ubihw closed 2 years ago

ubihw commented 2 years ago

I don't know if it's an error, or a misconfiguration/misconception on my side: If I try to connect to TM1 with SSO, I get an error, stating a missing dependency. My test file:

import TM1py

tm1params = {
    "address"   : "tm1-server",
    "port"      : 19191,
    "namespace" : "Firma",
    "gateway"   : "http://cognos-server/ibmcognos/bi/v1/disp", # same as ClientCAMURI in tm1s.cfg
    "ssl"       : True,
}

tm1 = TM1py.Services.TM1Service(**tm1params)

The result:

Traceback (most recent call last):
  File "C:\Users\ubihw\AppData\Roaming\Python\Python39\site-packages\TM1py\Services\RestService.py", line 476, in _build_authorization_token_cam
    HttpNegotiateAuth
NameError: name 'HttpNegotiateAuth' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\test.py", line 13, in <module>
    tm1 = TM1py.Services.TM1Service(**tm1params)
  File "C:\Users\ubihw\AppData\Roaming\Python\Python39\site-packages\TM1py\Services\TM1Service.py", line 15, in __init__
    self._tm1_rest = RestService(**kwargs)
  File "C:\Users\ubihw\AppData\Roaming\Python\Python39\site-packages\TM1py\Services\RestService.py", line 200, in __init__
    self._start_session(
  File "C:\Users\ubihw\AppData\Roaming\Python\Python39\site-packages\TM1py\Services\RestService.py", line 352, in _start_session
    token = self._build_authorization_token(
  File "C:\Users\ubihw\AppData\Roaming\Python\Python39\site-packages\TM1py\Services\RestService.py", line 467, in _build_authorization_token
    return RestService._build_authorization_token_cam(user, password, namespace, gateway, verify)
  File "C:\Users\ubihw\AppData\Roaming\Python\Python39\site-packages\TM1py\Services\RestService.py", line 478, in _build_authorization_token_cam
    raise RuntimeError(
RuntimeError: SSO failed due to missing dependency requests_negotiate_sspi.HttpNegotiateAuth. SSO only supported for Windows

Fresh install of Python 3.9, and of TM1py 1.8.

We use IntegratedSecurityMode=5, and accessing web sheets via http://tm1-server:9510/tm1web/UrlApi.jsp with SSO works.

It's my first attempt to SSO with TM1py, though.

Any hints?

rkvinoth commented 2 years ago

Are you running this script in windows? If not, SSO will not work. If yes, install request negotiate sspi package using pip install requests-negotiate-sspi

ubihw commented 2 years ago

Yes, it is in windows, and requests-negotiate-sspi is installed:

C:\>pip list
Package                 Version
----------------------- ---------
certifi                 2021.5.30
charset-normalizer      2.0.6
et-xmlfile              1.1.0
idna                    3.2
mdxpy                   0.3
openpyxl                3.0.9
pip                     21.2.4
pypiwin32               223
pytz                    2021.1
pywin32                 301
requests                2.26.0
requests-negotiate-sspi 0.5.2
setuptools              57.4.0
TM1py                   1.8.0
urllib3                 1.26.7
MariusWirtz commented 2 years ago

I think you may have two installations of python.

One in your local AppData and a global one.

Navigate to the scripts folder in the global installation (C:\Python3\Scripts) and run the pip install again.

ubihw commented 2 years ago

OK. My Python installation was one for all users, a global one, into C:\Program Files\Python39. After that, I used pip in a cmd.exe, which was not started as Administrator. Apparently, that caused the TM1py Installation including it's dependencies to go into C:\Users....

After cleaning all up and doing a fresh Install as Administrator, my SSO test works.

Thanks for guiding me.