Forum Discussion

korffr's avatar
korffr
Contributor
5 years ago

API Access issue with / without SSO

Hi Everyone, I am migrating discussions from another platform to a board here.

Initially we created an account that was not using SSO, so I was able to create a script that would login with user.login and user.password.

That worked all fine, however I think company admin script has likely cleaned up accounts that were not linked to an SSO account, so I am unable to proceed.

To get around that we created a new SSO account, and linked that to the API account we used earlier.

However this also means I have to get the token from the SSO client, rather than directly through username password.

I was told that I could use the LISESSIONID that is generated through a browser login and stored in a cookie, and use that. Since this is more or less a one-time exercise, that would solve my issue,  however I am running in some problems.

The error message I get is that I am not authorized to make this request.

{"status":"error","message":"You are not authorized to make this request","data":{"type":"error_data","code":203,"developer_message":"","more_info":""},"metadata":{}}

The account does have API privileges, so not sure what is happening... Any help is appreciated.

 

Thanks,


Richard Korff

2 Replies

  • A bit more detail on the API calls. The variale LIAPISESSIONKEY is filled with the value of LISESSIONID cookie from my browser. Which runs on the same machine.

    curl -X POST \
        https://community.microfocus.com/api/2.0/messages \
        -H 'content-type: application/json' \
        -H "li-api-session-key: $LIAPISESSIONKEY" \
        -d '{
                "data":{
                    "type":"message",
                    "subject":"Test Subject",
                    "body":"API Test body",
                    "board":{
                        "id":"Management"
                    }
                }
            }'

  • NarendraG's avatar
    NarendraG
    Khoros Alumni (Retired)
    5 years ago

    Hi korffr LiSESSIONID is a cookie session id and li-api-session-key is a session token, they both are different.

    instead of li-spi-session-key header, pass the LiSESSIONID as a cookie in the curl request with -b or --cookie option. It should work.

    for example:

    curl -X POST \
        https://community.microfocus.com/api/2.0/messages \
        -H 'content-type: application/json' \
        -b "LiSESSIONID=<session_id_from_a_logged_in_cookies_section_of_your_browser>" \
        -d '{
                "data":{
                    "type":"message",
                    "subject":"Test Subject",
                    "body":"API Test body",
                    "board":{
                        "id":"Management"
                    }
                }
            }'