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
187 stars 107 forks source link

TM1py SSO login not authorised #1065

Closed zzatang closed 5 months ago

zzatang commented 6 months ago

I am trying to run the following script to login to TM1:

from TM1py.Services import TM1Service

with TM1Service(address=tm1server_address, port=12223, ssl='True', integrated_login=True) as tm1: print(tm1.server.get_product_version())

But it returns with this error: TM1pyRestException: Text: '' - Status Code: 401 - Reason: 'Unauthorized'

The TM1 instance is setup using IntegratedSecurityMode 3 and I can login to it using Perspective without any issue.

Version

MariusWirtz commented 5 months ago

For WIA you might need to provide additional arguments, such as the server principal name (spn).

Here you find all relevant arguments: https://gist.github.com/MariusWirtz/fef8a8083d987e8c964000059540b48b#file-tm1-login-integrated-custom-py

MariusWirtz commented 5 months ago

Please let us know if you were able to resolve it

zzatang commented 5 months ago

Thank you @MariusWirtz. Would you be able to explain what this integrated_login_service=servicename is? I have checked the config file for our TM1 server but I can't see anywhere mentions integrated login service

MariusWirtz commented 5 months ago

TM1py uses requests_negotiate_auth. You can find details about the arguments here: https://github.com/brandond/requests-negotiate-sspi/tree/master

This is the mapping between TM1Service arguments and requests-negotiate-arguments:

requests-negotiate-sspi Argument TM1py Argument
domain integrated_login_domain
service integrated_login_service
host integrated_login_host
delegate integrated_login_delegate
zzatang commented 5 months ago

Hi @MariusWirtz,

It still does not work. Interestingly though, when I downgrade TM1py to version 1.10.1, it is ok to connect with just specifying address, port, ssl and integrated_login. But it does not work when I upgrade it to latest version even I specify value to all parameters you mentioned before.

MariusWirtz commented 5 months ago

Is this perhaps related to https://github.com/cubewise-code/tm1py/issues/1074 ? Please upgrade to the current master branch and verify if the issue is resolved.

pip uninstall tm1py
pip install https://github.com/cubewise-code/tm1py/archive/refs/heads/master.zip

We will draft a new minor release shortly.

zzatang commented 5 months ago

Thank you @MariusWirtz. This works.