function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raj_SRaj_S 

Login to Salesforce using POST or GET request.

Is it possible to login to the salesforce using Post / Get request?? I mean i want to open my salesforce Home page directly by using my organization username and password with the URL(www.salesforce.com) string.

                  Thanks





Raj S
Raj_SRaj_S
Actually i tried by this code

            string strusername = UserName;
            string strpassword = Password;

            ASCIIEncoding encoding = new ASCIIEncoding();
            string postData = "username=" + strusername;
            postData += ("&password=" + strpassword);
            byte[] data = encoding.GetBytes(postData);

            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://na6.salesforce.com/home/home.jsp");
            myRequest.Method = "POST";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            myRequest.ContentLength = data.Length;
           
            myRequest.Proxy = new System.Net.WebProxy("1.1.1.1", 8080);
            myRequest.Proxy.Credentials = new System.Net.NetworkCredential("XYZ", "ABC", "123");

            Stream newstream = myRequest.GetRequestStream();
            newstream.Write(data, 0, data.Length);
            newstream.Close();

           But I got this Error :
            Length = 'newstream.Length' threw an exception of type 'System.NotSupportedException'

Can someone help me out in this.

Thanks!

Raj S

           
Mike LeachMike Leach

I think https://login.salesforce.com/ is the primary gateway for authentication now.

Viewing the source (below), I wonder if posting the hidden values would achieve what you're looking for.

Code:
 <FORM NAME="login" ACTION="https://login.salesforce.com/" METHOD="POST" onSubmit="handleLogin();" BASE TARGET="_top" >
                    <INPUT TYPE="hidden" NAME="un" VALUE="">

                    <INPUT TYPE="hidden" NAME="width" VALUE="">
                    <INPUT TYPE="hidden" NAME="height" VALUE="">
                    <INPUT TYPE="hidden" NAME="jse" ID="jse" VALUE="0">
                    <INPUT TYPE="hidden" NAME="hasRememberUn" VALUE="true">
                    <INPUT TYPE="hidden" NAME="local" VALUE="">
                    <INPUT TYPE="hidden" NAME="startURL" VALUE="">
                    <INPUT TYPE="hidden" NAME="loginURL" VALUE="">
                    <INPUT TYPE="hidden" NAME="loginType" VALUE="">
                    <INPUT TYPE="hidden" NAME="useSecure" VALUE="true">

                    <INPUT TYPE="hidden" NAME="lt" VALUE="standard">
                    <INPUT TYPE="hidden" NAME="qs" VALUE="">
                    <INPUT TYPE="hidden" NAME="locale" VALUE="">
                    <INPUT TYPE="hidden" NAME="oauth_token" VALUE="">
                    <INPUT TYPE="hidden" NAME="oauth_callback" VALUE="">
<input type="text" id="username" name="username"  value="" tabindex="1" class="std" />
<input type="password" id="password" name="pw" tabindex="2" class="std" onKeyPress="checkCaps(event)" />


 

Richie DRichie D

create a simple form with  a "get" method. have 2 fields un and pw for the username and password. A url of the form shown below will be created and log you in. You can try it by putting into the url your username and password to test.

https://login.salesforce.com/?un=blah@blah.com&pw=mypassword

something like...
Code:
<form action="https://login.salesforce.com/" method="get">

<input id="un" name="un"/>
<input id="pw" name="pw"/>
<input type="submit" name="login" value="login"/>
</form>

 
Rich.
Raj_SRaj_S
Thanks so much!