Solved

How to use gooddata API with node js

  • 27 January 2023
  • 7 replies
  • 114 views

I tried calling gooddata API with necessary headers using node js but it is showing error 401. If possible it will be really helpful to get a sample code

icon

Best answer by Jan Rehanek 30 January 2023, 15:08

View original

7 replies

Userlevel 2

Can you please provide more details on what you're trying to achieve and which API you're trying to call? 

Please could you also send us the code you're currently using too? 

Once we have more details, we will be happy to look into this further for you. 

Thank you!

This the function which I am calling on index js and I want to get all the users from the given workspace ID

Userlevel 3

Thanks for the screenshot. May I know what is the exact error you are getting? Do you have an error ID? 

Thanks, 

 

-Moises

Its error 401

Userlevel 3

Hey Sasal,

There’s two tokens to keep track of here.

  • SST - Super Secure Token
    • It is used to generate a TT
  • TT - Temporary Token
    • It is used to interact with GoodData’s API endpoints

This concept is further described here: https://help.gooddata.com/doc/enterprise/en/expand-your-gooddata-platform/api-reference#tag/token

In short, /gdc/account/login returns an SST that you can’t use, for example, to list users, which is why you’re getting this error.

What you should do:

  1. POST request to gdc/account/login will return an SST. You have this part already.
  2. GET request to /gdc/account/token with the X-GDC-AuthSST header that contains the SST. X-GDC-AuthSST is used because you are using verify_level 2. This will return a TT.
  3. Any request to some API endpoint with the X-GDC-AuthTT header that contains the TT. This will allow you, for example, to list those users.

Does that make sense?

Userlevel 3

Further info on the SST and its expiration: https://help.gooddata.com/doc/enterprise/en/expand-your-gooddata-platform/gooddata-platform-overview/gooddata-token-types/sst-session-expiration

Thanks I got it. I really appreciate the help

Reply