I have just upgraded to Revolution Enterprise 3.0 and am trying to implement the basic Google login API via the post command but am not having much luck.
on mouseUp
set the sslCertificates to "/usr/share/curl/curl-ca-bundle.crt"
put URLEncode("Email=myNmme@gmail.com&Passwd=myPassword&source=gwt-lagb-1&service=cl&accountType=HOSTED_OR_GOOGLE") into myPost
post myPost to URL "https://www.google.com/accounts/ClientLogin"
put the result into field "myResult"
end mouseUp
I get error 403 Forbidden (BadAuthentication error) returned from Google.
However if I use cURL in a bit of sample code I found in the forums everything seems to work fine. One of the reasons I upgraded was to take avantage of the SSL capabilities without having to use cURL.
I really want to use Revolution as opposed to Adobe AIR to develop some internal "mashups" but a lot of them require SSL.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
on mouseUp
set the sslcertificates to "/usr/share/curl/curl-ca-bundle.crt"
put "Email=myEmail.net&Passwd=myPassword&source=gwt-lagb-1&service=cl&accountType=HOSTED_OR_GOOGLE" into tPost
put "https://www.google.com/accounts/ClientLogin" into tUrl
post tPost to url tUrl
put the result & cr & it
end mouseUp
No urlencoding, which is weird, since the docs say:
Data you send should be encoded using the URLEncode function.
I copied your entire code replacing only my email and password and am still getting the same result which makes me think there is something else going on. I can using the login manually at Google's site so I know it's not that.
libUrlSetSSLVerification false
put "https://www.google.com/accounts/ClientLogin" into theURL
put libUrlFormData("accountType", "GOOGLE", \
"Email", theEmail, \
"Passwd", thePassword, \
"service", "xapi", \
"source", "Blue Mango Learning Systems-ScreenSteps-2.1") into theData
post theData to theURL
put it
I recieved a 200 response header back (I used libURLSetLogField to watch the request/response headers) and 'it' contained the SID, LSID and Auth values.
So it appears that it should work assuming the username/password is correct.
That worked perfectly! However in my thirst to understand Revolution much better than I do now can you explain why this method works and my attempt using post to URl does not?
Also where is libUrlSetSSLVerification documented?
I obviously have a long way to go to really understand the power of Revolution!
Actually I just left the 'URL' out by mistake. I just add it into my test and the code still works (post theData to URL theURL).
I didn't realize that libUrlSetSSLVerification isn't documented but it basically doesn't use certificates to verify that the server on the other end is really the server it is supposed to be. Fine for testing but it can be a security risk.
I just tried the following code and it worked as well:
on mouseUp pMouseBtnNo
libUrlSetSSLVerification true
set the sslcertificates to "/usr/share/curl/curl-ca-bundle.crt"
put "https://www.google.com/accounts/ClientLogin" into theURL
put libUrlFormData("accountType", "GOOGLE", \
"Email", theEmail, \
"Passwd", thePassword, \
"service", "xapi", \
"source", "Blue Mango Learning Systems-ScreenSteps-2.1") into theData
post theData to URL theURL
put the result & cr & it
end mouseUp
Give it a try and let me know if it works for you as well.
Last edited by trevordevore on Fri Sep 26, 2008 6:15 pm, edited 1 time in total.
All of the sudden I am getting BadAuthorization errors returned from Google even though nothing has changed which leads me to believe there is something within Google's system that may be causing for whatever reason.
Would you have any idea about Google's limits especially if you have bad attempts?
I've done some more digging and the problem seems to be within Revolution. I added additional code and the first time through everything works fine. But any other tries produces the BadAuthorization error. If I quit Revolution and then restart the script again runs fine the first time.
on mouseUp
libUrlSetSSLVerification false
set the sslcertificates to "/usr/share/curl/curl-ca-bundle.crt"
put "myName@gmail.com" into theEmail
put "myPassword" into thePassword
put "https://www.google.com/accounts/ClientLogin" into theURL
put libUrlFormData("accountType", "HOSTED_OR_GOOGLE", \
"Email", theEmail, \
"Passwd", thePassword, \
"service", "cl", \
"source", "gwt-lagb-1") into theData
post theData to theURL
put it into field "output"
--read the AUTH string
 set the itemdelimiter to "="
 put the last item of field "Output" into AUTH
 put "http://www.google.com/calendar/feeds/default/owncalendars/full" into curlURL
  put "Content-type: application/atom+xml" &LF &"Authorization: GoogleLogin auth=" &AUTH into field "HEADER"
 set the httpheaders to field "HEADER"
 get URL curlURL
 put it into field "Output"
 --Google sends a SSID cookie that has to be included if the first attempt fails
 if field "Output" contains "Moved Temporarily" then
  put offset("gsessionid=",field "Output") into fcharSSID
  put offset(">here<",field "Output")- 2 into lcharSSID
  put char (fcharSSID) to (lcharSSID) of field "Output" into SSID
  post field "newevent" to curlURL &"?" &SSID
  put it into field "Output"
 end if
end mouseUp
Is there something I should be "unloading" after each call?
I have just discovered the problem. I didn't realize that when I set the httpHeaders further down in my script with additional custom information that data hangs around after the script has finished running. So subsequent calls to the same script would already have the httpHeaders set which was wrong for Google's Client Login requirements. By setting the httpHeaders to empty after making any custom calls eliminates the problem.
I guess I didn't realize that the httpHeaders was a "global" if you will.
Sigh.
So much to learn!
Thanks for everyone's help. I really appreciate the timely responses.
I found this old post and I wonder if there is any further info on RunRev/Google calendar connections. Would be nice some example stack...
What I need is the ability to connect, download to a text file all the G calendars and be able to upload a new text file with the replacement of all the calendars on Google Cal.
Is this feasible ?