I'm working on a project and I want to log into SO via curl.
I use Google as my openID provider which means that I need to log into Google first via its API.
Here is the code I have so far
#!/usr/bin/env sh
. ./params.sh #the script with $username and $password
curl --silent https://www.google.com/accounts/ClientLogin \
-d Email=$username -d Passwd=$password \
-d accountType=GOOGLE \
-d source=localhost-test-1 \
-d service=lso \
-o tokens
. ./tokens
echo $Auth; #$Auth is correct here - I did not get a BadAuth error.
endpoint="https://www.google.com/accounts/o8/id";
curl http://stackoverflow.com/users/authenticate \
-d "openid_identifier=$endpoint" \
-w %{redirect_url}> ./google_url
google_url=$(cat ./google_url);
echo $google_url;
echo;
echo;
echo;
curl -L --silent --header "Authorization: GoogleLogin auth=$Auth" $google_url;
At this point I get a page from google telling me that stack overflow wants information and I have to log in. According to http://code.google.com/apis/gdata/articles/using_cURL.html the --header ... $Auth part should count as a login and redirect me to stack overflow.
Here is the form I get when I run this script:
<form id="gaia_universallogin"
action="https://www.google.com/accounts/ServiceLoginAuth?service=lso" method="post">
<input type="hidden" name="continue" id="continue"
value="https://www.google.com/accounts/o8/ud?st=SOME_KEY" />
<input type="hidden" name="service" id="service"
value="lso" />
<input type="hidden" name="dsh" id="dsh"
value="SOME_NEG_NUMBER" />
</form>
When I try the answer below I get the following error:
Can't call method "attr" on an undefined value at - line 8.
curl: (3) <url> malformed
-->
here is the output from google2.html
<form id="gaia_loginform"
action="https://www.google.com/accounts/ServiceLoginAuth?service=lso" method="post" >
<input type="hidden" name="continue" id="continue" value="https://www.google.com/accounts/o8/ud?st=RNADOM" />
<input type="hidden" name="service" id="service" value="lso" />
<input type="hidden" name="dsh" id="dsh" value="NEG_NUMEBER" />
<input type="hidden" name="GALX" value="ABCD" />
<input type="text" name="Email" id="Email" />
<input type="password" name="Passwd" id="Passwd" >
<input type="checkbox" name="PersistentCookie" id="PersistentCookie" value="yes"
<input type="hidden" name='rmShown' value="1" />
<input type="submit" class="gaia le button" name="signIn" id="signIn" />
<input type="hidden" name="asts" >
</form>