Forum Discussion

dsharma's avatar
dsharma
Adept
2 years ago

How to create API accessible user account with Community

I am new to Khoros platform and want to crawl data from community. For that I did signup process with one lithium community and got my username and password. 

I am trying to authenticate myself with via retrieve-the-session-key but api response says 

curl --location --request \
    POST 'https://community.alteryx.com/restapi/vc/authentication/sessions/login' \
    --form 'user.login=dshrm' \
    --form 'user.password=****'
<response status="error">
  <error code="302">
    <message>
      User authentication failed.
    </message>
  </error>
</response>

I am trying to get user details via LiQl basic query `select * from users limit 1`

What exactly process do I need to follow to authenticate myself ?

  • Disclaimer: I am not an engineer

    Are you using restadmin instead of rest?  This seems to always trick up engineers on their first attempt using Khoros.  (You want to use restadmin!)

    edit: Our engineer says I am probably wrong, so, you should probably ignore my advice ðŸ¤£

    • dsharma's avatar
      dsharma
      Adept

      No, I am not using restadmin. I just followed the mentioned steps in the Question.

    • dsharma's avatar
      dsharma
      Adept

      Hi MohammedSh , thanks for taking time. 

      I tried with sso as well, still not able to authenticate

       curl --location --request \                                                                                             
          POST 'https://community.alteryx.com/restapi/vc/authentication/sessions/login' \
          --form 'user.login=dshrm' \
          --form 'user.password=*****' \
          --form 'sso.authentication_token=66231595-191e-4353-9e9e-e5906dbf7f0e'

       

      I tried with removing password field , removing user.login but nothing worked. 
      Here sso token used in the valid generated UUID. 
      Is token something different to be used here or can be used anything to uniquely identifies?

  • Or alternatively you can create a non SSO account in the USERS tab in admin just for API use. Then you should be able to get a session key for that account.

    Make sure to make the account an Admin account if you want to use it to retrieve any private information or if you are using FreeMarker you can use restadmin like StanGromer suggested.

    Also, if you are only after publicly visible information, LiQl does not require any authentication.

     

  • MartinD's avatar
    MartinD
    Khoros Alumni (Retired)

    You don't need authentication to run that liql query, you can just try this call and will work

     
    curl --location --request GET 'https://community.alteryx.com/api/2.0/search?q=select%20*%20from%20users%20limit%201'
    • dsharma's avatar
      dsharma
      Adept

      Thanks MartinD , It worked. 

      Actually for the first attempt, I signup with community cisco and tried to get result as 

      curl --location --request GET 'https://community.cisco.com/api/2.0/search?q=select%20*%20from%20users%20limit%201'

       and it returned 200 response but empty users data.  From documentation, I interpreted as that user data might not be available to anonymous users and hence i signup with them. 

      But then i was not able to authenticate myself as described in question. 

      Could you help me with the reason or any findings that why i am not getting users details from cisco community ? 

       

      • MartinD's avatar
        MartinD
        Khoros Alumni (Retired)

        dsharma there are some communitites with this setting set on false

        restapi.v2.enable_anon_user_collection_access = false

        If this setting is false then an anonymous user can not get the user data if he is not logged in

  • dsharma, thank you for trying with SSO. As per your above comment, it seems like MartinD solution worked. However, if you still face any issues, I suggest you raise a support ticket to investigate internally and help you. 

  • MartinD , What is supposed to be used for authentication_token in sso login as you suggested? 

    Where do i get this token from ?