[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Has anybody had any experience accessing Google Apps web services from HTTPAPI?
Nice timing! I am looking at Google Docs right now. From what I've seen, most of the "services" are straight POST or GET with some special substitutions.
For the login, "regular" Login still works. I haven't seen that anyone has worked out OAuth using HTTPAPI. If you go to Java land or even PHP, you can probably do it easier as it has been written there.
I have a working ClientLogin. I think the service for calendar is "cl". I didn't write ParseAuth right at this point and there is leftover code in the program. I should be calling Incoming in Post_Raw and making a big variable with the data after doing ASCII/EBCDIC translation. Then Parse Auth should be called after getting all the data. The next thing would be to take the authString variable and add it to the header (Authorization: GoogleLogin auth=yourAuthValue). It needs to be passed on each subsequent POST or GET.
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')
/define WEBFORMS
D/copy qrpglesrc,httpapi_h
D cmd pr extpgm('QCMDEXC')
D command 200A const
D length 15P 5 const
D CRLF C CONST(x'0D25')
D rc s 10I 0
D msg s 52A
D Form s like(WEBFORM)
D accountType s 100A varying
D Email s 100A varying
D Passwd s 100A varying
D service s 100A varying
D source s 100A varying
D myPointer s *
D dataSize s 10I 0
d ParseAuth pr 10i 0
d descriptor 10i 0
d data 8192a options(*varsize)
d dataLen 10i 0 value
d authString s 8192a varying
/free
http_debug(*on);
accountType = 'HOSTED_OR_GOOGLE';
Email = 'xxxxxxxx@xxxxxxxxx';
Passwd = 'zzzzzzzzzzzzzzzzzz';
service = 'writely'; // change to match service
source = 'MK-GDOCS01-3.0'; // as best I can tell - made up value
Form = WEBFORM_open();
WEBFORM_SetVar(Form: 'accountType': accountType );
WEBFORM_SetVar(Form: 'Email' : Email );
WEBFORM_SetVar(Form: 'Passwd' : Passwd );
WEBFORM_SetVar(Form: 'service' : service );
WEBFORM_SetVar(Form: 'source' : source );
WEBFORM_postData( Form : myPointer : dataSize );
rc = http_url_post_raw(
'https://www.google.com/accounts/ClientLogin'
: myPointer
: dataSize
: 1
: %paddr('PARSEAUTH')
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'application/x-www-form-urlencoded' );
if rc <> 1;
msg = http_error;
dsply msg;
else;
// get list of documents
rc = http_url_get(
'https://docs.google.com/feeds/default/private/full':
'/tmp/google.docs');
// https://www.google.com/calendar/feeds/default/allcalendars/full will return XML so you could call http_url_get_xml
endif;
WEBFORM_close(Form);
*inlr = *on;
/end-free
p ParseAuth b
d ParseAuth pi 10i 0
d descriptor 10i 0
d data 8192a options(*varsize)
d dataLen 10i 0 value
d startSID s 10i 0
d startLSID s 10i 0
d startAuth s 10i 0
/free
startSID = %scan('SID=' : data );
startLSID = %scan('LSID=' : data : startSID );
startAuth = %scan('Auth=' : data : startLSID );
AuthString = %subst(data : startAuth);
return 1;
/end-free
p ParseAuth e
-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of James Lampert
Sent: Tuesday, November 15, 2011 3:16 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: Has anybody had any experience accessing Google Apps web services from HTTPAPI?
Finally getting back to this thread.
The specific part of Google Apps that we're trying to interface with
from the 400 is Google Calendar. Anybody have any experience dealing
with that?
Some of the docs I've been reading lately on this project talk about
"2-legged OAuth," apparently intended for web apps, that would be ideal
for what we're doing, IF it can be made to work from a 400. But I'm
drowning in the docs, with no frame of reference for a lot of the things
they discuss. If anybody is in a position to throw me a metaphorical
"life ring," I'd greatly appreciate it.
--
James H. H. Lampert
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------