I created the REST API call with basic authentication.But I think it is hard coded.
I need to send current logged username and password as authentication to rest api.
Can anyone help me with this?
Hi,
the question is missing some information.
The external REST API you try to query is using BASIC AUTH for authentication. This means you pass username and password in the Authorization Header and the REST API authenticates against the Credentials Provider configured at the REST API to get access.
When you log on to a OutSystems application it depends on the User Provider (or App) Configuration what Credentials Provider is used to authenticate you as a user. The basic configuration is to use the internal Users table which authenticates your account using a username and a password. The password is stored hashed in the users table.
When your user provider is configured to use an external Credentials provider than you authenticate against e.g. Azure AD using SAML. After you have authenticated at your credentials provider the OutSystems User Provider looks up a corresponding user record in the Users table and either creates a new user record or uses an existing user account to log you in. (In this case the password attribute in the users table is not relevant as authentication is already performed externally).
Long story short. Dependant on your configuration the USERNAME in your OutSystems users table may be the same USERNAME used by your REST APIs credential provider for authentication. BUT the PASSWORD stored in the users record is mostly likely different (except you have some custom sync method for the hashed and salted passwords).
Anyhow you cannot retrieve the plain text password from the user record.
For authentication to an external REST API you can
* Create a service account in your REST APIs Credentials provider and use this one for authentication. This of course is a machine-to-machine communiation and does not give you the possibility for delegated rights (user access rights).
* Try to find an alternative solution for REST API authentication/authorization like OAuth Access Tokens or Cookie based authentication.
Best
Stefan
Please check below thread,
https://www.outsystems.com/forums/discussion/22162/set-rest-api-basic-authentication/
Thanks.
Thanks @Ajit Kurane.This is very helpful.
But one question,
How can I get the current log in username and password?
Hi ,
You need to add depedencey and select user_login action from users module.
Please check steps in below document,
https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Expose_REST_APIs/Add_Basic_Authentication_to_an_Exposed_REST_API
Hope it helps you.
Thanks,
Ajit Kurane.
Hello @Ajit Kurane .
As I am using Consume REST API,I take this thread https://www.outsystems.com/forums/discussion/22162/set-rest-api-basic-authentication/ as reference, u mentioned above.
Using the user database from 'System' I get username but password is not stored in it.
Can I get using any other way?
Thanks @Stefan Weber.