337
Views
6
Comments
Solved
Basic authorisation on exposed REST API for ODC
Question

Hi, I want to expose a REST API in ODC with basic authorisation. I found this documentation about it on OutSystems: https://success.outsystems.com/documentation/outsystems_developer_cloud/building_apps/exposing_rest_apis/expose_a_rest_api/.

For O11 the idea is that you do a server-side login in your OnAuthorisation request. Here you validate the user to the database.

For ODC, there is not yet a server or service action available that does the login. Only a client action is available, which of course cannot be used in an API flow. 
Is there a way in ODC to use basic authorisation for an exposed REST API without a "login" server/service action?

I hope anyone  can help me.

Kind regards.

UserImage.jpg
Alex Ruinen
Solution

Hi Miguel,

The solution that Daniel and Aurelio proposed, worked before. You didn't need some library. However, I ended up not implementing this flow.

I just checked to help you again, and it indeed seems that the old way of adding the User_Login from the public elements once you set the authentication to "basic", is not possible anymore. I'm sorry I cannot help you, but I am interested once you find the solution.

 

2019-09-30 07-35-56
Aurelio Junior
Solution

Hi Alex,

OutSystems has disabled this recently, and currently there's no alternative. So Basic Authentication is currently not supported in ODC.

What I'm doing in an ODC project I'm currently working on is using Custom Authentication for the API, and then, in the "OnAuthentication" action, validating a token supplied by the API consumer in the request header. This is what the flow looks like:

Be advised that you're going to have to manage the tokens yourself. I've created a small backoffice application to help me with that.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Alex,

Actually there is, you should be able to use the User_Login action, see screenshot:

Regards,

Daniel

UserImage.jpg
Alex Ruinen

Hi Daniel, I wanted to use this again, but just as Miguel, I am unable to find it. Do you perhaps know what happened, or how we can find it again?

2019-09-30 07-35-56
Aurelio Junior
Solution

Hi Alex,

OutSystems has disabled this recently, and currently there's no alternative. So Basic Authentication is currently not supported in ODC.

What I'm doing in an ODC project I'm currently working on is using Custom Authentication for the API, and then, in the "OnAuthentication" action, validating a token supplied by the API consumer in the request header. This is what the flow looks like:

Be advised that you're going to have to manage the tokens yourself. I've created a small backoffice application to help me with that.

2019-09-30 07-35-56
Aurelio Junior

To whoever might stumble upon this thread in the future, the way this works is that as soon as you set the authentication of an exposed API to "Basic", the reference to the "User_Login" action is automatically added. You don't have to add it manually.

2019-11-08 14-27-49
Miguel Riso Almeida

Hi all,

I've tried to add the User_Login action but i can't fetch it on public elements. Is the example given in ODC? is there a specific version where this is working, or should I import some library?

UserImage.jpg
Alex Ruinen
Solution

Hi Miguel,

The solution that Daniel and Aurelio proposed, worked before. You didn't need some library. However, I ended up not implementing this flow.

I just checked to help you again, and it indeed seems that the old way of adding the User_Login from the public elements once you set the authentication to "basic", is not possible anymore. I'm sorry I cannot help you, but I am interested once you find the solution.

 

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