Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Thu Sep 25, 2008 10:17 pm
Hi,
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.
Here is the code that is not working:
Code: Select all
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.
Any and all help would be greatly appreciated.
Thanks,
Gary
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Thu Sep 25, 2008 11:16 pm
Hi Gary,
Are you sure that Google accepts urls of that form (application/x-www-form-urlencoded)?
I'm not sure that the entire url should be urlEncoded. Try
Email=urlEncode(
myNmme@gmail.com)&Passwd=urlEncode(myPassword)&source=gwt-lagb-1&service=cl&accountType=HOSTED_OR_GOOGLE")
Best,
Mark
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
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Thu Sep 25, 2008 11:42 pm
Hi Mark,
I gave your idea a try but got the same result.
Is there something different regarding the post command when used with https?
Thanks,
Gary
-
Mark Smith
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
-
Contact:
Post
by Mark Smith » Fri Sep 26, 2008 1:04 am
I just tried this, and succeeded:
Code: Select all
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.
Does that work for you?
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Fri Sep 26, 2008 1:34 am
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.
This is really strange.
Are you using Revolution Enterprise 3.0?
Thanks for all of your help.
Gary
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Fri Sep 26, 2008 3:35 pm
Gary,
For readability I like to use libURLFormData(). I tried the following in Rev 3.0 gm-3 with my Google account info and it worked:
Code: Select all
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.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Fri Sep 26, 2008 3:51 pm
Hi Trevor,
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!
Thanks for everyone's help!
Gary
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Fri Sep 26, 2008 4:04 pm
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:
Code: Select all
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.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Fri Sep 26, 2008 4:12 pm
It still works for me as well.
I assume this is fake data in your example!
Thanks for your help!
Gary
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Fri Sep 26, 2008 4:26 pm
Hi Trevor,
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?
Thanks for your help.
Gary
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Fri Sep 26, 2008 5:44 pm
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.
Here is the script in question:
Code: Select all
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?
Thanks for everyone's help!
Gary
-
gwthompson
- Posts: 15
- Joined: Thu Feb 14, 2008 8:37 pm
Post
by gwthompson » Fri Sep 26, 2008 6:02 pm
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.
Gary
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Fri Sep 26, 2008 6:19 pm
Glad you got it working Gary.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
trevix
- Posts: 1064
- Joined: Sat Feb 24, 2007 11:25 pm
-
Contact:
Post
by trevix » Sun Jan 17, 2010 3:49 pm
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 ?
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>
-
trevix
- Posts: 1064
- Joined: Sat Feb 24, 2007 11:25 pm
-
Contact:
Post
by trevix » Mon Jan 18, 2010 2:15 pm
One more thing...
Do I need RunRev enterprise, to connect to Google calendar ? Vannot be done from Studio ?
Thanks
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>