1. mike S
  2. PowerServer
  3. Monday, 6 November 2023 15:08 PM UTC

I use the restclient to get the JWT token from powerserver web api since that is how the examples show how to do it.

 

From what i can tell however, all the GetJWTToken does is post to the url and put the response body in the 'ref string token' and deflate it if it is in gzip format.  You still have to use jsonparser to get the token:  GetItemString("/access_token")  

 

is there any reason to use the restclient for this other than the auto-deflate?  If the ExtractorObject supported in memory extraction rather than requiring output to files, then the http client would be the same?

Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 7 November 2023 10:09 AM UTC
  2. PowerServer
  3. # 1

Hi Mike,

RESTClient is using HTTPClient internally. RESTClient provides some simpler methods for common scenarios of REST API (e.g.: you can call Retrieve to import response JSON to a Datawindow), so you can save some code to consume common REST APIs.

In fact, you can use HTTPClient and other objects to implement the same code when sending a POST HTTP request to get a JWT token.

Regards, Logan

Comment
  1. Kevin Ridley
  2. Wednesday, 8 November 2023 16:34 PM UTC
Agreed! Anything you do with RESTClient you can do with HTTPClient, plus alot more. I always use HTTPClient unless it's a very simple API with simple, flat (not hierarchical) response data.
  1. Helpful
  1. mike S
  2. Wednesday, 8 November 2023 18:06 PM UTC
what about the auto-deflate as part of restclient? I assume that happens in memory with the restclient, whereas with httclient you need to use the extractor and save it first to a file? Or does the restclient just save it to a file and then read it back into memory?



It's weird that the examples for the JWT token processing use restclient. I don't think that the built in JWT service uses compression on the body, so there is zero reason to use it for powerserver JWT tokens.



  1. Helpful
  1. Armeen Mazda @Appeon
  2. Wednesday, 8 November 2023 18:55 PM UTC
  1. Helpful 2
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.