is it possible to do gmail login in iframe?

896 views
Skip to first unread message

iammikecohen

unread,
Jul 8, 2008, 5:42:30 PM7/8/08
to Google Data Protocol
I'm using the example JS to interact with google data but I want the
page that I'm redirected to to be in an iframe. How do I call
google.accounts.user.login() and give it a target?

var contactsService;
function setupContactsService() {
contactsService = new
google.gdata.contacts.ContactsService('exampleCo-exampleApp-1.0');
}

function logMeIn() {
var scope = 'http://www.google.com/m8/feeds';
var token = google.accounts.user.login(scope);
}
function getMyContacts() {
var contactsFeedUri = 'http://www.google.com/m8/feeds/contacts/
default/full';
var query = new google.gdata.contacts.ContactQuery(contactsFeedUri);

// Set the maximum of the result set to be 5
query.setMaxResults(5);

contactsService.getContactFeed(query, handleContactsFeed,
handleError);
}

var handleContactsFeed = function(result) {
var entries = result.feed.entry;
var list = 'addy ';
for (var i = 0; i < entries.length; i++) {
var contactEntry = entries[i];
var emailAddresses = contactEntry.getEmailAddresses();

for (var j = 0; j < emailAddresses.length; j++) {
var emailAddress = emailAddresses[j].getAddress();
list = list + emailAddress + " ";
}
}
alert('email = ' + list);

}
function handleError(e) {
alert("There was an error!");
alert(e.cause ? e.cause.statusText : e.message);
}
function initFunc() {
setupContactsService();
logMeIn();
getMyContacts();

}
google.load("gdata", "1.x");


google.setOnLoadCallback(initFunc);

Jeff Fisher (Google)

unread,
Jul 9, 2008, 4:44:13 PM7/9/08
to Google Data Protocol
Hi,

It seems that this is just how the JavaScript client library works to
prevent fishing (since anyone can make a real-enough login window pop
up). You can try to do some tricks by having the JavaScript client
library run in an iframe, but due to the restrictions against
accessing the content of iframes, I'm not sure how you'd be able to
get the token back out.

Cheers,
-Jeff
Reply all
Reply to author
Forward
0 new messages