i need to consume API for external user login
Application Type
Mobile

Hi everyone 

Im new to outsystems, i try to cutomize login mobile apps using 3rd party REST API, i need to consume the API and store the token was generate by REST API that i consume . is it possible to using external rest api for login ?


Hi 

You can use the REST customization capabilities to add support for other authentication methods: For token-based authentication, use the "OnBeforeRequest" callback to add the required HTTP authorization header to the outgoing requests. 


Best Regards

Shubham

Hi Mr shubam


thank you for your response, do you have some sample or more explanation ?


Best Regards

Yansen

Hi


I don't have a sample prepared yet but I can prepare one and send it to you as soon as I have it.

Hi,


you can refer this post , if you want to send Authentication Token in External REST API .


Consume REST API and Send Custom Headers in OnBeforeRequest...

https://www.outsystems.com/forums/discussion/40945/consume-rest-api-and-send-custom-headers-in-onbeforerequest/#Post147822


i will create sample app if you still needed...

Hi Mr Sanjay


Thank you Mr Sanjay, i will wait for sample, very grateful for your help 

1. Using Outsystems default Login Screen, 

      a. you can check if userid is null then you can call external api for authenticate user. 

      b. if success then you will find user in Outsystems User table [ using userid or email  depends upon use case, if your are getting unique identification from token to  identify use, you can use that ].  if user found in OS DB then you can create session/login using userid without password. if user not exist then you can create user in outsystem DB and then create login/session in outsystems and continue.

c. if you want to logout , you can call external api to log out and destroy session in outsystms. DB.

2. using external SSO login screen, like Office 365 . 

                you can check if userid is null then you will redirect to SSO login screen using external URL. you have to create a callback screen so that SSO will send Token in to header or body of callback screen back to your app. you will get user's unique id from header or body then you can perform same flow as i described above.  you can refer Outsystem IDP integration for more detail.

    

hi @Sanjay Sahu 

i already find external user in outsystems user table, now i need to store the token was automaticly generate when i consume login api 

Hi @yosua yansen,

I will share a demo that I already had. Please check the OnbeforeRequest callback here I am sending AppId and Key. You can append your token to the header and send it through the customized request.

Regards,

Sreejith Surendran

APICRUD.oml

Hi @yosua yansen , Let us know if the OML shared by @Sreejith Surendran fulfill your need.


Thanks

Shubham

Hi @Sreejith Surendran and @Shubham Tiwari

first thanks for your sample i learn a lot, but still little bit confuse maybe because it was my first task to intergrate 2 apps (try to consume external apps single sign on rest api ),
second the token is generate when i consume the API, and i need to store it ( like sharedpreference in androidstudio java) , maybe any specific sample or explaination

Can you explain a little more about it? Here you are getting the token as a response to the login API call, so you want to store that token and pass that token to another API request. Let me know if there any misunderstanding from my side.

Hi @Sreejith Surendran


Thanks for your response, so i have external apps call it SSO ( Single Sign On) it's like a portal that user to access other application by token was stored, so the app i'm working on in outsystems, is consume the API and the response is getting the token, so i try to store the token (i need to know how token can be stored )

Here you cannot store that from the Logic tab (at the time of consuming). But you can store that token from the action flow which you use to sign in.

In the login button, you call the login method in the API  so there you will get the response (token) from there only you can store that token to any local variable or client or client variable.

hope this will help you!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.