yoandypv
yoandypv

Reputation: 11

PHP Rest client for JHipster API with session auth

I have developed a system using Jhipster and its technologies. I'm trying now to create a REST client in PHP to connect to the API generated by Jhipster, but I could not authenticate. I've tried with php_curl, guzzle and I always get 401.

Please if anyone has any client rest for the Jhipster API and knows how to achieve authentication I would appreciate your help. I am using session for authentication in Jhipster / spring

Upvotes: 0

Views: 697

Answers (1)

Julien Dubois
Julien Dubois

Reputation: 3688

Session authentication might not be the easiest authentication mechanism for such a use-case, maybe JWT would be better for you.

What you need to do is go through the authentication form (do a "POST" and send the login/password), and that will give you a token (a "jsessionid", this is the standard for Java application). You can check this if you use Chrome Dev Tools.

Then, you need to use this "jsessionid" for your next requests.

If you generate your application with the "Gatling" option (in the available tests frameworks), this will generate the correct configuration for doing the authentication and doing the requests: Gatling is coded in Scala, but that will give a good example, which you can copy.

Upvotes: 1

Related Questions