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
190 stars 109 forks source link

Unable to obtain CAM_Passport using new 'gateway' parameter #129

Closed user1493 closed 5 years ago

user1493 commented 5 years ago

Code:

import configparser
config = configparser.ConfigParser()
config.read(r'C:\Users\RAVIVK\virtualtest\TM1py-samples-master\TM1py-samples-master\config.ini')

from TM1py.Services import TM1Service

# Connect to TM1
with TM1Service(**config['tm1srv01']) as tm1:
    pass

Error:

Traceback (most recent call last):
  File "C:\Users\virtualtest\test.py", line 11, in <module>
    with TM1Service(**config['tm1srv01']) as tm1:
  File "C:\Users\virtualtest\lib\site-packages\TM1py\Services\TM1Service.py", line 12, in __init__
    self._tm1_rest = RESTService(**kwargs)
  File "C:\Users\virtualtest\lib\site-packages\TM1py\Services\RESTService.py", line 123, in __init__
    decode_b64=self.translate_to_boolean(kwargs.get("decode_b64", False)))
  File "C:\Users\virtualtest\lib\site-packages\TM1py\Services\RESTService.py", line 204, in _start_session
    gateway)
  File "C:\Users\virtualtest\lib\site-packages\TM1py\Services\RESTService.py", line 284, in _build_authorization_token
    return RESTService._build_authorization_token_cam(user, password, namespace, gateway)
  File "C:\Users\virtualtest\lib\site-packages\TM1py\Services\RESTService.py", line 302, in _build_authorization_token_cam
    "Failed to authenticate through CAM. HTTP response does not contain 'cam_passport' cookie")
RuntimeError: Failed to authenticate through CAM. HTTP response does not contain 'cam_passport' cookie

Config:

[tm1srv01]
user=
password=
address=12345
port=9049
namespace=abcd
gateway=https://********
ssl=True

TM1 version: 10.2.2 FP7 Intigrated security mode: 5 with SSO

Should I follow the below idea? Is it secure? https://github.com/cubewise-code/tm1py/issues/124#issuecomment-491852908

MariusWirtz commented 5 years ago

Hi @user1493 ,

your parameters look alright. Judging from the Error you get, it seems that TM1py did communicate with the CAM gateway, but somehow the cam_passport was not returned from the gateway.

That sounds very much like the problem @christianthieme was describing in #124 It seems some security is blocking your request to the CAM Server.

I would recommend to follow the idea expressed in #124 or check with your IT department if there are easier ways to get around this issue.

Does the script fail when you run it on the same machine that runs the CAM Server ?

user1493 commented 5 years ago

If I provide the user and password and leave the gateway parameter empty, TM1py is able to communicate and scripts succeeds without error. But with gateway it fails even if I provide the user and password.

Sorry, but which machine would run the CAM server? Is it the Server in which the TM1 Server windows services are located?

Also https://github.com/cubewise-code/tm1py/issues/124#issuecomment-491852908 is not feasible if I deliver my scripts to other users as they would lack the web driver software and can't force people to install. Is this the only solution or are you proposing it as a timely workaround?

MariusWirtz commented 5 years ago

This is not surprising. If you provide user and password, then TM1py is will use User and Passoword for authentication and not go through CAM SSO.

The machine that you specified in the ClientCAMURI.

If the trick from #124 works, then you know that there is something (most likely security) blocking you from acquiring the cam_passport from the CAM gateway.

If you are not too familiar with the CAM authentication for TM1 perhaps it's easiest to simply stick with user and password.

user1493 commented 5 years ago

Okay, I will try out the steps posted in https://github.com/cubewise-code/tm1py/issues/124#issuecomment-491852908 and come back with the results.

Will try to understand the usage of CAM authentication for TM1 as well.