How to pass login credentials in external url outside Outsystems

Hello guys,

I'm trying to pass credentials in url of the insurance campany to login automatically in the website that was not developed in Outsystems. It was suggested to use POST request to /login.php with username and password parameters. I tried to use PostRequest_AddArgument Action and PostRequest_Submit Action but without success. Also I tried this code but without success as well.

<form action="http://insurancecompany.com/privatearea/?postlogin" method="post">

Login: <input type="text" name="Login"><br>

Password: <input type="text" name="Password"><br>

<input type="submit" value="Login">

</form>

Anyone had this problem in past?

Thanks

Hi John,

Could you please elaborate it more what exactly you wanted achieve ? I am assuming you need to send this request from your Outsystems application to the other application for authentication?


Regards,

-PJ-

Hi John,

Please check on the insurance ccompany website login page if they have more fieds (may be hidden) in their login form like remember me, anti forgery token etc. Usually login forms have more then just username and password.

Hi Jhon,

I agree with Nikhil, you need to check the variable or hidden fields which are there in the Login Form. You can able to check it by Inspecting through browsers. So you will get the proper variable counts and also proper variable name.

I hope this will solve your issue.

Thank you,

Sudip

Pramod Jain wrote:

Hi John,

Could you please elaborate it more what exactly you wanted achieve ? I am assuming you need to send this request from your Outsystems application to the other application for authentication?


Regards,

-PJ-

Hi Pramod,

Yes, I need to send this request from my Outsystems application to the other application for authentication.

Thanks.




Sudip Dey wrote:

Hi Jhon,

I agree with Nikhil, you need to check the variable or hidden fields which are there in the Login Form. You can able to check it by Inspecting through browsers. So you will get the proper variable counts and also proper variable name.

I hope this will solve your issue.

Thank you,

Sudip

Hi Sudip and Nikhil,

Yes, I already tried to check the variables which are there in the Login Form. The HTML code for the input login is

<input name="_58_login" id="usuario" type="text" class="c-textinput__field c-textinput__field--floating js-floating__input is-filled" autocomplete="off"> 

and for input password is:

<input name="_58_password" id="password" type="password" class="c-textinput__field c-textinput__field--floating js-floating__input is-filled" maxlength="8" autocomplete="off">


I tried to use the HTML code from this website:

https://stackoverflow.com/questions/6248679/automatic-login-script-for-a-website-on-windows-machine 

I put this code in expression with Escape Content = No.

" <!doctype html>
<!-- saved from url=(0014)about:internet -->

<html>
<title>Autologin</title>
</head>
<body>
<form id='loginForm' name='loginForm' method='post' action='https://www.insurancecampany.com/private-area'>
    <select name='uni_url' id='logServer' class='validate[required]'>
        <option  class=''  value='insurancecampany.com' fbUrl=''  cookieName=''  >
                Test_en
        </option>
    </select>
    <input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />
                            </form>
<script>document.loginForm.submit();</script>      
</body></html>"


When I run the code, appeared in Outsystems webpage the Input Login and the Input Password filled with the values and after I was redirected to insurance campany webpage but the fields of credentials was not filled.


Do you know what I'm doing wrong?


Thank you for your answers.

Regards.




As per the coding, it should take the value to the main page for the check login details. I think the value is taking by using id with ajax validation. That can be the reason not to taking the value to the log page. Do you have access to the login action page of the website?

I guess the issue. You can able to check that if possible. Otherwise, everything is fine, I think so. It should work if the value taking from the input field name.

Please check and let me know,

Thank you,

Sudip

Sudip Dey wrote:

As per the coding, it should take the value to the main page for the check login details. I think the value is taking by using id with ajax validation. That can be the reason not to taking the value to the log page. Do you have access to the login action page of the website?

I guess the issue. You can able to check that if possible. Otherwise, everything is fine, I think so. It should work if the value taking from the input field name.

Please check and let me know,

Thank you,

Sudip

Yes, the login action page of the website is https://www.allianz.pt/area-privada

The code is:

<html>
<title>Autologin</title>
</head>
<body>
<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>
    <select name='uni_url' id='logServer' class='validate[required]'>
        <option  class=''  value='allianz.pt' fbUrl=''  cookieName=''  >
                Test_en
        </option>
    </select>
    <input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />
                            </form>
<script>document.loginForm.submit();</script>      
</body></html>

Thank you for your answer.

You are always welcome. 

Sudip Dey wrote:

You are always welcome. 

Do you know how can I avoid the ajax validation?


you can send the data getElementById in the form submit. it will pass the data by using Id of the Input field.

I hope this way you can pass the data.

Please check and let me know,

Thank you,

Sudip

john3423 wrote:

Sudip Dey wrote:

Hi Jhon,

I agree with Nikhil, you need to check the variable or hidden fields which are there in the Login Form. You can able to check it by Inspecting through browsers. So you will get the proper variable counts and also proper variable name.

I hope this will solve your issue.

Thank you,

Sudip

Hi Sudip and Nikhil,

Yes, I already tried to check the variables which are there in the Login Form. The HTML code for the input login is

<input name="_58_login" id="usuario" type="text" class="c-textinput__field c-textinput__field--floating js-floating__input is-filled" autocomplete="off"> 

and for input password is:

<input name="_58_password" id="password" type="password" class="c-textinput__field c-textinput__field--floating js-floating__input is-filled" maxlength="8" autocomplete="off">


I tried to use the HTML code from this website:

https://stackoverflow.com/questions/6248679/automatic-login-script-for-a-website-on-windows-machine 

I put this code in expression with Escape Content = No.

" <!doctype html>
<!-- saved from url=(0014)about:internet -->

<html>
<title>Autologin</title>
</head>
<body>
<form id='loginForm' name='loginForm' method='post' action='https://www.insurancecampany.com/private-area'>
    <select name='uni_url' id='logServer' class='validate[required]'>
        <option  class=''  value='insurancecampany.com' fbUrl=''  cookieName=''  >
                Test_en
        </option>
    </select>
    <input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />
                            </form>
<script>document.loginForm.submit();</script>      
</body></html>"


When I run the code, appeared in Outsystems webpage the Input Login and the Input Password filled with the values and after I was redirected to insurance campany webpage but the fields of credentials was not filled.


Do you know what I'm doing wrong?


Thank you for your answers.

Regards.




Hi John,

If you are sure that there are only username and password field in the login form nothing else then as Sudip shared login page might be working using ajax and for that you have to check in network tab in chrome developer tools to see where request is being sent on login button click.

Will be good if you can share the link of your login page so that we can directly see and suggest better.


Oh, I was a little late. You already got the discussion ahead of where I joined :)

Nikhil Gaur wrote:

john3423 wrote:

Sudip Dey wrote:

Hi Jhon,

I agree with Nikhil, you need to check the variable or hidden fields which are there in the Login Form. You can able to check it by Inspecting through browsers. So you will get the proper variable counts and also proper variable name.

I hope this will solve your issue.

Thank you,

Sudip

Hi Sudip and Nikhil,

Yes, I already tried to check the variables which are there in the Login Form. The HTML code for the input login is

<input name="_58_login" id="usuario" type="text" class="c-textinput__field c-textinput__field--floating js-floating__input is-filled" autocomplete="off"> 

and for input password is:

<input name="_58_password" id="password" type="password" class="c-textinput__field c-textinput__field--floating js-floating__input is-filled" maxlength="8" autocomplete="off">


I tried to use the HTML code from this website:

https://stackoverflow.com/questions/6248679/automatic-login-script-for-a-website-on-windows-machine 

I put this code in expression with Escape Content = No.

" <!doctype html>
<!-- saved from url=(0014)about:internet -->

<html>
<title>Autologin</title>
</head>
<body>
<form id='loginForm' name='loginForm' method='post' action='https://www.insurancecampany.com/private-area'>
    <select name='uni_url' id='logServer' class='validate[required]'>
        <option  class=''  value='insurancecampany.com' fbUrl=''  cookieName=''  >
                Test_en
        </option>
    </select>
    <input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />
                            </form>
<script>document.loginForm.submit();</script>      
</body></html>"


When I run the code, appeared in Outsystems webpage the Input Login and the Input Password filled with the values and after I was redirected to insurance campany webpage but the fields of credentials was not filled.


Do you know what I'm doing wrong?


Thank you for your answers.

Regards.




Hi John,

If you are sure that there are only username and password field in the login form nothing else then as Sudip shared login page might be working using ajax and for that you have to check in network tab in chrome developer tools to see where request is being sent on login button click.

Will be good if you can share the link of your login page so that we can directly see and suggest better.


I Nikhil,

The link of my login page is https://www.allianz.pt/area-privada.

Thanks.


Hi Jhon,

The user name and Password value which you are using is not exist in the system. Please use the proper username and password in the value section of the input variable.


 <input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />


I hope this will work fine. Currently which you using is not a real user name and password of the website.


Thank you,

Sudip


Sudip Dey wrote:

Hi Jhon,

The user name and Password value which you are using is not exist in the system. Please use the proper username and password in the value section of the input variable.


 <input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />


I hope this will work fine. Currently which you using is not a real user name and password of the website.


Thank you,

Sudip


Hi Sudip,

Yes, the user name and password that I put in code is not correct but what I want is the input login and input password appear filled. After the user click in enter button.

I tried to do what you suggest sending the data with getElementById:

 <script>
        function Test() {
        document.getElementById("loginForm").method = "post";
        document.getElementById("usuario").value = "examplelogin";
        document.getElementById("password").value = "examplepassword";
        window.open("https://www.allianz.pt/area-privada", "_blank");
        }      
    </script> 

But this script is not working yet.

Can you help me with this code?

Thanks for your help.

Below will be the function... 


function Test() 

 {

var name = document.getElementById("usuario").value;

var password= document.getElementById("password").value;

document.getElementById("loginForm").submit();  //form submission

}



Please check and let me know your feedback,

Thank you,

Sudip

john3423 wrote:

Sudip Dey wrote:

Hi Jhon,

The user name and Password value which you are using is not exist in the system. Please use the proper username and password in the value section of the input variable.


 <input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />


I hope this will work fine. Currently which you using is not a real user name and password of the website.


Thank you,

Sudip


Hi Sudip,

Yes, the user name and password that I put in code is not correct but what I want is the input login and input password appear filled. After the user click in enter button.

I tried to do what you suggest sending the data with getElementById:

 <script>
        function Test() {
        document.getElementById("loginForm").method = "post";
        document.getElementById("usuario").value = "examplelogin";
        document.getElementById("password").value = "examplepassword";
        window.open("https://www.allianz.pt/area-privada", "_blank");
        }      
    </script> 

But this script is not working yet.

Can you help me with this code?

Thanks for your help.

Also I try this:

<head runat="server">
    <title></title>
    <script>
        function OpenPage()
        {
            var input = 'inputexample';
            var pass = 'inputpassword';
            var OpenWindow = window.open('https://www.allianz.pt/area-privada');
            OpenWindow.document.getElementById('usuario').value = input;
            OpenWindow.document.getElementById('password').value = pass;
             
        }
    </script>
</head>

I went to the webpage but the inputs was not fill.

There is a action in Outsystems that can do this automatically?


Thanks.


it will not work on window .open. as it is not submitting the data. you have to do as I sent you. The same format. the submit button will be onclick function. like the below...

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>


Please use the below...


 <script>

function Test() 

 {

var name = document.getElementById("usuario").value;

var password= document.getElementById("password").value;

document.getElementById("loginForm").submit();  //form submission

}

 </script>

<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>

<input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>

</form>


I hope this will work,

Thank you,

Sudip

Sudip Dey wrote:

Please use the below...


 <script>

function Test() 

 {

var name = document.getElementById("usuario").value;

var password= document.getElementById("password").value;

document.getElementById("loginForm").submit();  //form submission

}

 </script>

<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>

<input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>

</form>


I hope this will work,

Thank you,

Sudip

Unfortunately it doesn't work. When I click in submit button, the button doesn't make anything. Does this code work for you?

Thanks


This is the full code



<!DOCTYPE html>

<html>

<body>

 <script>

function Test() 

 {

var name = document.getElementById("usuario").value;

var password= document.getElementById("password").value;

document.getElementById("loginForm").submit();  //form submission

}

 </script>

<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>

<input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>

</form>

</body>
</html>



I forgot to put the HTML tags. This is the working code.

Thanks,

Sudip

Sudip Dey wrote:

This is the full code



<!DOCTYPE html>

<html>

<body>

 <script>

function Test() 

 {

var name = document.getElementById("usuario").value;

var password= document.getElementById("password").value;

document.getElementById("loginForm").submit();  //form submission

}

 </script>

<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>

<input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
    <input id='password' name='_58_password' type='password' value='examplepassword' class='' />

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>

</form>

</body>
</html>



I forgot to put the HTML tags. This is the working code.

Thanks,

Sudip

It doesn't work yet. You put the code in a expression and when you click in submit button you go to the webpage https://www.allianz.pt/area-privada?

Thanks


I have checked this login page and noticed that apart from username and password there are many more fields in the form which are hidden. You also have to keep them in your form while submitting.

Nikhil Gaur wrote:

I have checked this login page and noticed that apart from username and password there are many more fields in the form which are hidden. You also have to keep them in your form while submitting.

I Nikhil,

I tried to do your suggestion but it doesn't work yet.

<!DOCTYPE html>
<html>
<body>
<script>
function Test()
 {
var name = document.getElementById("usuario").value;
var password= document.getElementById("password").value;
document.getElementById("loginForm").submit();  //form submission
}
 </script>

<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>

<input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
<input id='password' name='_58_password' type='password' value='examplepassword' class='' />
<input type='hidden' id='technology' name='_58_technology' value='' />
<input type='hidden' id='platform' name='_58_platform' value='' />
<input type='hidden' id='connection' name='_58_connection' value='' />
<input type='hidden' id='ie' name='_58_ie' value='' />
<input type='hidden' id='mvm' name='_58_mvm' value='' />
<input type='hidden' id='axo' name='_58_axo' value='' />
<input type='hidden' id='cookies' name='_58_cookies' value='' />
<input type='hidden' id='js' name='_58_js' value='' />
<input type='hidden' id='jws' name='_58_jws' value='' />
<input type='hidden' id='screen' name='_58_screen' value='' />
<input type='hidden' id='patch' name='_58_patch' value='' />
<input type='hidden' id='browrender' name='_58_browrender' value='' />
<input type='hidden' id='redirectAutoservice' name='_58_redirectAutoservice' value='' />

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>

</form>
</body>
</html>


I also try this function but also it doesn´t work.


function Test() {
    document.getElementsByTagName('form')[0].action='https://www.allianz.pt/area-privada';
    document.getElementsByTagName('form')[0].target = '_self';
    document.getElementsByTagName('form')[0].method='POST';
   
    document.getElementsByClassName('_58_login')[0].name='_58_login';
    document.getElementsByClassName('_58_password')[0].name='_58_password';
    document.getElementsByClassName('_58_technology')[0].name='';
    document.getElementsByClassName('_58_platform')[0].name='';
    document.getElementsByClassName('_58_connection')[0].name='';
    document.getElementsByClassName('_58_ie')[0].name='';
    document.getElementsByClassName('_58_mvm')[0].name='';
    document.getElementsByClassName('_58_axo')[0].name='';
    document.getElementsByClassName('_58_cookies')[0].name='';
    document.getElementsByClassName('_58_js')[0].name='';
    document.getElementsByClassName('_58_jws')[0].name='';
    document.getElementsByClassName('_58_screen')[0].name='';
    document.getElementsByClassName('_58_patch')[0].name='';
    document.getElementsByClassName('_58_browrender')[0].name='';
    document.getElementsByClassName('_58_redirectAutoservice')[0].name='';
}


Do you know what I'm doing wrong?

Thanks for all helps.


Hi Jhon,

you need to fetch it ById not class and also needs to pass the proper value for the fields. I hope there should be some value in particular fields. also needs to add  document.getElementById("loginForm").submit();  to submit the form. 

I hope it should work.


Thank you,

Sudip


Also why you put [0] and why use the getElementsByClassName ?

There is no Class in the input field.  Please use GetElementById.


Thank you,

Sudip

Sudip Dey wrote:

Also why you put [0] and why use the getElementsByClassName ?

There is no Class in the input field.  Please use GetElementById.


Thank you,

Sudip

Hi Sudip,

I put [0] and the getElementsByClassName because I tried the solution of this post: https://www.outsystems.com/forums/discussion/27828/post-form/ .

The fields that have not values are fiels that appear in https://www.allianz.pt/area-privada with type=hidden and they have no value. I tried to do the suggestion of Nikhil. 


Do you know why this code doesn't work?


<!DOCTYPE html>
<html>
<body>
<script>
function Test()
 {
var name = document.getElementById("usuario").value;
var password= document.getElementById("password").value;
document.getElementById("loginForm").submit();  //form submission
}
 </script>

<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>

<input id='usuario' name='_58_login' type='text' value='examplelogin' class='' />
<input id='password' name='_58_password' type='password' value='examplepassword' class='' />
<input type='hidden' id='technology' name='_58_technology' value='' />
<input type='hidden' id='platform' name='_58_platform' value='' />
<input type='hidden' id='connection' name='_58_connection' value='' />
<input type='hidden' id='ie' name='_58_ie' value='' />
<input type='hidden' id='mvm' name='_58_mvm' value='' />
<input type='hidden' id='axo' name='_58_axo' value='' />
<input type='hidden' id='cookies' name='_58_cookies' value='' />
<input type='hidden' id='js' name='_58_js' value='' />
<input type='hidden' id='jws' name='_58_jws' value='' />
<input type='hidden' id='screen' name='_58_screen' value='' />
<input type='hidden' id='patch' name='_58_patch' value='' />
<input type='hidden' id='browrender' name='_58_browrender' value='' />
<input type='hidden' id='redirectAutoservice' name='_58_redirectAutoservice' value='' />

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>

</form>
</body>
</html>


Thank you for your help.

Hi,

Put the proper value in the hidden field and hope it will work afterwords.

Thank you,

Sudip

Sudip Dey wrote:

Hi,

Put the proper value in the hidden field and hope it will work afterwords.

Thank you,

Sudip

Hi Sudip,

I put values in the hidden field but unfortunately it still doesn't work.


Also I tried run this code in Javascript of WebScreen, in option Advanced, and in create a button with a RunJavaScript function with value "Test()" and when I clicked in button give me this error: "An exception occurred in the client script. Error: document.getElementById(...) is null".

The form should not be within the function?


<!DOCTYPE html>
<html>
<body>
<script>
function Test()
 {
var name = document.getElementById("usuario").value;
var password= document.getElementById("password").value;
document.getElementById("loginForm").submit();  //form submission
}
 </script>

<form id='loginForm' name='loginForm' method='post' action='https://www.allianz.pt/area-privada'>

<input id='usuario' name='_58_login' type='text' value='examplelogin' class='c-textinput__field c-textinput__field--floating js-floating__input is-filled' />
<input id='password' name='_58_password' type='password' value='examplepassword' class='c-textinput__field c-textinput__field--floating js-floating__input is-filled' />
<input type='hidden' id='technology' name='_58_technology' value='a' />
<input type='hidden' id='platform' name='_58_platform' value='a' />
<input type='hidden' id='connection' name='_58_connection' value='a' />
<input type='hidden' id='ie' name='_58_ie' value='a' />
<input type='hidden' id='mvm' name='_58_mvm' value='a' />
<input type='hidden' id='axo' name='_58_axo' value='a' />
<input type='hidden' id='cookies' name='_58_cookies' value='a' />
<input type='hidden' id='js' name='_58_js' value='a' />
<input type='hidden' id='jws' name='_58_jws' value='a' />
<input type='hidden' id='screen' name='_58_screen' value='a' />
<input type='hidden' id='patch' name='_58_patch' value='a' />
<input type='hidden' id='browrender' name='_58_browrender' value='a' />
<input type='hidden' id='redirectAutoservice' name='_58_redirectAutoservice' value='a' />

<input type="button" name="submit" id="btn" value="Submit" onclick="Test()"/>

</form>
</body>
</html>


Thank you for your help.



Hi

Did you able to solve it?  Please let me know,

Thank you,

Sudip

Hi,

No because with Javascript I can't make a browser load a third-party page containing data I provide. That would generally involve a CSRF and/or XSS attack which sites usually defend themselves against.

Do you know if with C# code I can autofill credentials of an external webpage?

Thanks

You can fill credentials to an external page using desktop app in C# but not in web application with outsystems extension.

Nikhil Gaur wrote:

You can fill credentials to an external page using desktop app in C# but not in web application with outsystems extension.

Hi Nikhil,


Thanks for your answer. You saved me a lot of time.

I am currently trying another approach. I am trying to pass the credentials of a external webpage from the Outsystems cloud to a password manager like Enpass or LastPass. Basically I want these app browsers to fetch the credentials from the outsystems cloud. 

Do you know if this is possible?


Thanks again for your help.