using POST to login to a webserver using REST api in mendix

0
I am trying to login to an external webserver using a mendix REST microflow but cannot find a good example or documentation that is helpful. Here is what I am trying to do. register a user on an external webserver use a username and password to login to that external webserver get a return token, save it and use it in the subsequent calls   Please give me some pointers for this example.
asked
1 answers
2

Here are some pointers that may help:

  1. Refer to this documentation for calling the REST service in general – https://docs.mendix.com/refguide/call-rest-action#3-http-headers
  2. It seems like you will have to use custom HTTP headers for your REST calls including the initial authentication POST call. Take a look at the information in this forum question – https://forum.mendix.com/link/questions/91485,  it has the OAuth authentication token handling.
  3. In combination with the above forum question,  please take a look at couple of these related model shares from experts –
    https://modelshare.mendix.com/models/c0c55b74-ab42-4898-8cf0-6f2686041950/token-get-or-create
    https://modelshare.mendix.com/models/2a27e93c-7865-45c4-9040-c55a094ae047/retrieve-account-object-with-inheritance
  4. Basically, you will see from the example above that once you have accessed the authentication token from the POST response header, you could store it in an entity associated with your Account and retrieve it for subsequent REST calls. If you decide to store it in a persistent entity, it will probably require some delete behavior to clean up this entity whenever the session gets removed.
  5. Alternatively, you could create a non-persistent entity to store the token and associate it directly to the session object. Session object is available in microflows as variable $CurrentSession and you could always retrieve the token from it for your subsequent REST calls.

 

answered