GMail authentication with GWT + GAE - works in development but fails in production

90 views
Skip to first unread message

Deepak Singh

unread,
Mar 26, 2012, 12:41:32 PM3/26/12
to google-we...@googlegroups.com
Hi All,

I am authenticating my users through GMail login in GWt + GAE environment. Code is as follows:

GWT code:

final Frame frameForGmail = new Frame();
final Image gmailIcon = Image.wrap(Document.get().getElementById("gmailIcon"));
final DialogBox loginPopUp = new DialogBox(true, false);


gmailIcon.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
commonRpcService.gmailLogin(new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("RPC Failed");
}
@Override
public void onSuccess(String result) {
if(emailValidation(result)) {
Document.get().getElementById("loginMsg").appendChild(new Label("Welcome "+result).getElement());
}else {
frameForGmail.setUrl(result);
loginPopUp.show();
}
}
});
}
});


Server side:

@Override
public String gmailLogin() {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if(user != null) {
HttpSession session = getThreadLocalRequest().getSession(true);
session.setAttribute("LOGGED_IN_USER_EMAIL_ID", user.getEmail());
return user.getEmail();
}else {
try {
                  // getThreadLocalResponse().sendRedirect(userService.createLoginURL(getThreadLocalRequest().getRequestURI()));
return userService.createLoginURL("www.yatrafinder.com");
} catch (Exception e) {
System.out.println("CommonRpcServiceImpl.gmailLogin() "+e.getMessage());
}
}
return "Login not validated";
}


The above code works fine in development mode. It loads Frame with default login screen for development and works fine everything.

But when i deploy this app to GAE 1.6.1, it fails to load the frame with gmail login screen. The DialogBox opens but with blank screen.
I could not find out why it is happening. Kindly help.

App engine settings is done properly with default authentication as google account.




Thanks in advance 
Deepak Singh

Deepak Singh

unread,
Mar 27, 2012, 11:06:41 AM3/27/12
to google-we...@googlegroups.com, google-a...@googlegroups.com
Any help pls. i am still stuck with it.
--
Deepak Singh

Joseph Lust

unread,
Mar 27, 2012, 9:34:52 PM3/27/12
to google-we...@googlegroups.com
Deepak,

Can you run your app in DevMode but using the remote server option so that calls are being sent out to the actual Google APIs? I find it useful as you can step through and debug the production code in Eclipse, but the backend code is in production.

Just disable the built in server option, and in the GWT tab and URL field put the full remote path where you normally see MyApp.html. Of course the code versions in each side my be identical or you can get RPC errors.


Sincerely,
Joseph

Deepak Singh

unread,
Mar 28, 2012, 12:15:47 PM3/28/12
to google-we...@googlegroups.com
The reason is that Gmail does not allow to be opened in Frame/IFrame. When i replace it with browser window, it works.

But i dont want my page to be refreshed, so any solution to avoid reloading the window in case of Gmail authentication ?

Thanks
Deepak

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/bIgyQw2-DWAJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh

Thomas Broyer

unread,
Mar 28, 2012, 12:41:20 PM3/28/12
to google-we...@googlegroups.com
Window.open() ?


On Wednesday, March 28, 2012 6:15:47 PM UTC+2, Deepak Singh wrote:
The reason is that Gmail does not allow to be opened in Frame/IFrame. When i replace it with browser window, it works.

But i dont want my page to be refreshed, so any solution to avoid reloading the window in case of Gmail authentication ?

Thanks
Deepak

On Wed, Mar 28, 2012 at 7:04 AM, Joseph Lust wrote:
Deepak,

Can you run your app in DevMode but using the remote server option so that calls are being sent out to the actual Google APIs? I find it useful as you can step through and debug the production code in Eclipse, but the backend code is in production.

Just disable the built in server option, and in the GWT tab and URL field put the full remote path where you normally see MyApp.html. Of course the code versions in each side my be identical or you can get RPC errors.


Sincerely,
Joseph

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/bIgyQw2-DWAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh

Deepak Singh

unread,
Mar 28, 2012, 4:26:08 PM3/28/12
to google-we...@googlegroups.com
Hi Thomas,

I can not use Window.open() because after successful login, Gmail redirects user to the same window and there is no option to close the window automatically after login.



To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/mAAXGo4Y6F4J.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh

Thomas Broyer

unread,
Mar 29, 2012, 3:49:36 AM3/29/12
to google-we...@googlegroups.com
I don't know how Google/AppEngine (nothing to do with GMail) works exactly, but couldn't you make it redirect to some other page containing a script that talks to the window.opener and closes the window?


On Wednesday, March 28, 2012 10:26:08 PM UTC+2, Deepak Singh wrote:
Hi Thomas,

I can not use Window.open() because after successful login, Gmail redirects user to the same window and there is no option to close the window automatically after login.

On Wed, Mar 28, 2012 at 10:11 PM, Thomas Broyer  wrote:
Window.open() ?


On Wednesday, March 28, 2012 6:15:47 PM UTC+2, Deepak Singh wrote:
The reason is that Gmail does not allow to be opened in Frame/IFrame. When i replace it with browser window, it works.

But i dont want my page to be refreshed, so any solution to avoid reloading the window in case of Gmail authentication ?

Thanks
Deepak

On Wed, Mar 28, 2012 at 7:04 AM, Joseph Lust wrote:
Deepak,

Can you run your app in DevMode but using the remote server option so that calls are being sent out to the actual Google APIs? I find it useful as you can step through and debug the production code in Eclipse, but the backend code is in production.

Just disable the built in server option, and in the GWT tab and URL field put the full remote path where you normally see MyApp.html. Of course the code versions in each side my be identical or you can get RPC errors.


Sincerely,
Joseph

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/bIgyQw2-DWAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/mAAXGo4Y6F4J.

To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh
Reply all
Reply to author
Forward
0 new messages