Planning Analytics

Expand all | Collapse all

Sample connection string for RestAPI and mode 3

  • 1.  Sample connection string for RestAPI and mode 3

    Posted Thu October 22, 2020 06:37 AM
    Hi,
    We're trying to set up a RestAPI connection from R to PAL.
    We have this working with mode 1 security, however we need it to work with mode 3.
    Mode 3 is supported and touched on very briefly on page 9 of this document .

    Does anyone have a sample connection script for connecting in mode 3?

    Example of the mode 1 connection below.

    TIA for any pointers.

    ```{r}
    username <- "myusername"
    password <- "password"
    adminhost <- "host.name"
    httpport <- "23456"
    auth_type <- "Basic"

    usernamepwd <- paste(username, password, sep = ":")
    tm1_auth_key <- paste(auth_type, jsonlite::base64_enc(usernamepwd), sep = " ")

    httr::set_config(httr::config(ssl_verifypeer = FALSE))
    httr::set_config(httr::config(ssl_verifyhost = FALSE))

    u1 <- "https://"
    u2 <- adminhost
    u3 <- ":"
    u4 <- httpport
    u5 <- "/api/v1/Configuration"
    url <- paste0(u1, u2, u3, u4, u5)

    httr::GET(url, httr::add_headers(Authorization = tm1_auth_key))
    ```

    ------------------------------
    Steven Rowe
    ------------------------------


  • 2.  RE: Sample connection string for RestAPI and mode 3

    Posted Fri October 23, 2020 06:08 AM
    Hi Steven,

    As the document [briefly] touches on, it's following standard NEGOTIATE authentication pattern. I don't know R but googling for a sec tells me that the httr library you are using allows you to, instead of setting the Authorization header yourself, to use the authenticate instead in which you'd simply pass 'gssnegotiate' as the authentication method.

    Would that fix your problem?

    ------------------------------
    Hubert Heijkers
    ------------------------------



  • 3.  RE: Sample connection string for RestAPI and mode 3

    Posted Fri October 23, 2020 09:56 AM
    Hubert,
    Thanks for the pointer, I'll pass the info on and see if we get anywhere.
    All the best,
    Steve

    ------------------------------
    Steven Rowe
    ------------------------------



  • 4.  RE: Sample connection string for RestAPI and mode 3

    Posted 28 days ago

    How do you connect to TM1 using Rest API with CAM security mode 5?  Can you use a config.ini file to store settings?

     

    Here is what I have in the config file.  I got this working with CAM without a config.ini file within my python script.

     

    Config.ini file:

    [tm1srv01]

    address=ForQuest01

    user=rstevenson

    password=####

    namespace=ForQuest

    gateway=

    port=8046

    ssl=False

    decode_b64=True

     

    Py Script:

    with TM1Service(
       
    address='ForQuest01',
       
    port='8046',
       
    user='rstevenson',
       
    password='####',
       
    namespace='ForQuest',
       
    gateway=None,
       
    ssl=False) as tm1:

     

     






  • 5.  RE: Sample connection string for RestAPI and mode 3

    Posted 28 days ago

    How do you connect to TM1 using Rest API with CAM security mode 5?  Can you use a config.ini file to store settings?

    Here is what I have in the config file.  I got this working with CAM without a config.ini file within my python script.

    Config.ini file:

    [tm1srv01]

    address=ForQuest01

    user=rstevenson

    password=####

    namespace=ForQuest

    gateway=

    port=8046

    ssl=False

    decode_b64=True

     

    Py Script:

    with TM1Service(
        address='ForQuest01',
        port='8046',
        user='rstevenson',
        password='####',
        namespace='ForQuest',
        gateway=None,
        ssl=False) as tm1:



    ------------------------------
    Richard Stevenson
    ------------------------------



  • 6.  RE: Sample connection string for RestAPI and mode 3

    Posted 28 days ago
    Hi Richard / Rick, (Twins?)

    Thanks for this, interesting approach.  We have to use mode 3 and (for the moment at least) want to limit the solution to direct RestAPI calls only.

    From the info Hubert provided we have successfully made the connection from a windows OS to windows OS with

    > httr::GET(url, verbose(), authenticate(':', '', type='gssnegotiate'))

    However R is actually running on a unix machine, the same request from this machine does not work (we had had to update the url too), returning a 401 unauthorized error.
    We assume no general connectivity issues as this connection can be made from Unix to Windows with a mode 1 connection.

    Cheers



    ------------------------------
    Steven Rowe
    ------------------------------



  • 7.  RE: Sample connection string for RestAPI and mode 3

    Posted 28 days ago
    Hi Steve,

    I assume Python and R would have similar support for integrated security, I have never used R but if you look at how it is implemented in TM1Py that might give some tips. It uses the Negotiate protocol.

    The logic is in the RestService file: https://github.com/cubewise-code/tm1py/blob/master/TM1py/Services/RestService.py

    There are
    also some issue threads that may also help: https://github.com/cubewise-code/tm1py/issues?q=is%3Aissue++integrated+

    ------------------------------
    Tim Ryan - Cubewise
    ------------------------------