[google-appengine] The Users Service.
I have deployed: https://developers.google.com/appengine/docs/java/gettingstarted/usingusers I am greeted by my Gmail username when I visit the page. package com.clock; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.SimpleTimeZone; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.*; import com.google.appengine.api.users.User; import com.google.appengine.api.users.UserService; import com.google.appengine.api.users.UserServiceFactory; @SuppressWarnings(serial) public class ClockecsServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { SimpleDateFormat fmt = new SimpleDateFormat(-MM-dd hh:mm:ss.SS); fmt.setTimeZone(new SimpleTimeZone(0, )); UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); String loginUrl = userService.createLoginURL(/); String logoutUrl = userService.createLogoutURL(/); req.setAttribute(user, user); req.setAttribute(loginUrl, loginUrl); req.setAttribute(logoutUrl, logoutUrl); req.setAttribute(currentTime, fmt.format(new Date())); resp.setContentType(text/html); RequestDispatcher jsp = req.getRequestDispatcher(/WEB-INF/home.jsp); jsp.forward(req, resp); } } %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % html head titleThe Time Is.../title /head body c:choose c:when test=${user != null} p Welcome, ${user.email}! You can a href=${logoutUrl}sign out/a. /p /c:when c:otherwise p Welcome! a href=${loginUrl}Sign in or register/a to customize. /p /c:otherwise /c:choose pThe time is: ${currentTime}/p /body /html In the application above c:when test=${user != null} is not evaluating to anything and I am greeted by *Welcome! Sign in or register*. Since I am logged into Gmail it should display *Welcome! You can sign out * * * I am wondering if req.setAttribute(user, user); has set anything at all. It does not seem like it. I see what looks like a good call to User user = userService.getCurrentUser(); in the servlet. I don't see the problem yet. Does anyone know what could be wrong with the code? -- You received this message because you are subscribed to the Google Groups Google App Engine group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at http://groups.google.com/group/google-appengine. For more options, visit https://groups.google.com/groups/opt_out.
[google-appengine] Re: Users service with Chrome extension
On Apr 18, 5:45 pm, kernco colin.k...@gmail.com wrote: I'm building a Chrome extension that will talk to a backend GAE (python runtime) app to get some required data, and also as persistent data storage for the user. I'm not using HTML5 for the persistent data storage because GAE will allow users to log into the extension and have the same data no matter what computer they're on. My question is whether I can somehow use the GAE users service to do this. Basically I'm envisioning something like a browser action popup would show the GAE login screen, they log in with their google account, and then their credentials are stored in the chrome extension. Then the extension will make RPC calls to GAE, passing the credentials. Does that sound feasible? The part I'm most uncertain about is how, once the user logs into GAE, to transfer that login to the Chrome extension. Yes, but differently. Here's an example workflow for logins: 1. EXT -- APP -users.create_login_url()- API -- APP -- EXT 2. EXT popups the login_url and asks the user to submit 3. GOOG auths user, redir to APP 4. EXT's APP asks user to close the window 5. EXT can now store the cookie in HTML5 storage and call your RPC api all it wants sorry if this is somewhat confusing. -- You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appengine@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] Google Users service - Redirect URL - Cloud propagation delay
Hi all I had to spend 2 days to figure out a strange problem relating to using Google Users service. Problem: I recently enabled Google Accounts sign in in my app. But in production, when someone signs in with their Google account, the landing page (/trees/list.htm in my case) after the sign in returned None (null) for the users.get_current_user(), in Python. I think this problem would exist in Java world as well. Strangely, if I hit the landing page after 5 to 10 min in the same browser page, the function returned the signed in Google user!! Solution: I figured that this happens when the landing (redirect) page given to Google is *different* from the page that redirects or generates the link to the Google sign in page (/login.htm in my case), this 5 to 10 min of delay occurs when the users.get_current_user() api returns the signed in Google user. When I am instructing Google to redirect to the same page (login.htm) that generated the link to the Google sign page, this bug was solved. Possible explanation by me: It might be due to something like sticky sessions, in which the cloud server that generated the Google Login URL sees the signed up user instantly than the other servers in the cloud. So when the landing page is different from this URL, the request goes to some other machine in the cloud, where it takes 5 to 10 min for the data of Google user signed-in to be propagated!! Thoughts? -- Jagan -- You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
Re: [google-appengine] Google Users service - Redirect URL - Cloud propagation delay
Hi Jagan, Are you sure this isn't a caching issue? It's likely that the user's browser is returning the pre-login page to the user from cache, even after they've logged in. You can verify this by checking your logs to see if a new request was made, or by including a timestamp in the page. -Nick Johnson On Tue, Jun 15, 2010 at 9:22 AM, Jagan ksja...@gmail.com wrote: Hi all I had to spend 2 days to figure out a strange problem relating to using Google Users service. Problem: I recently enabled Google Accounts sign in in my app. But in production, when someone signs in with their Google account, the landing page (/trees/list.htm in my case) after the sign in returned None (null) for the users.get_current_user(), in Python. I think this problem would exist in Java world as well. Strangely, if I hit the landing page after 5 to 10 min in the same browser page, the function returned the signed in Google user!! Solution: I figured that this happens when the landing (redirect) page given to Google is *different* from the page that redirects or generates the link to the Google sign in page (/login.htm in my case), this 5 to 10 min of delay occurs when the users.get_current_user() api returns the signed in Google user. When I am instructing Google to redirect to the same page (login.htm) that generated the link to the Google sign page, this bug was solved. Possible explanation by me: It might be due to something like sticky sessions, in which the cloud server that generated the Google Login URL sees the signed up user instantly than the other servers in the cloud. So when the landing page is different from this URL, the request goes to some other machine in the cloud, where it takes 5 to 10 min for the data of Google user signed-in to be propagated!! Thoughts? -- Jagan -- You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.comgoogle-appengine%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en. -- Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047 Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047 -- You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.