Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved this exact issue for my app Push Actions - <a href="http://www.pushactions.com" rel="nofollow">http://www.pushactions.com</a>. For my solution, I did end up using GAE, but only to authenticate the token. The actual Push Actions app is hosted on Heroku. Here's my flow:</p> <ol> <li>Android app generates GAE token then posts the token &amp; the account's email address to Push Actions running on Heroku</li> <li>Push Actions posts the token to my service running on GAE</li> <li>The GAE service takes the token, determines if it is valid, and returns the email address it is valid for</li> <li>Push Actions compares the email address returned by GAE with the email address from the android app, if they match, the token is valid for that email address. This means the token can be safely associated with the google user's openid email address.</li> </ol> <p>As far as I know, this is the ONLY way to verify if a token generated by AccountManager is valid. True, it does require the use of GAE, but only for one small piece of your overall app. My GAE service ended up being like 1 class and a few lines of code, so it isn't much. You can think of the GAE piece as a service provided by google for authenticating tokens.</p> <p>Here is the code for my GAE service:</p> <pre><code>package com.pushactions; import java.io.IOException; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; 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 PushActionsAuthServlet extends HttpServlet { private static final Logger log = Logger.getLogger(HttpServlet.class.getName()); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { req.setAttribute("user", user); try { req.getRequestDispatcher("/logged_in.jsp").forward(req, resp); } catch (ServletException e) { log.severe("Couldn't redirect to logged_in.jsp"); } } else { try { req.getRequestDispatcher("/logged_out.jsp").forward(req, resp); } catch (ServletException e) { log.severe("Couldn't redirect to logged_out.jsp"); } } } } </code></pre> <p>logged_in.jsp:</p> <pre><code>&lt;%@ page import="com.google.appengine.api.users.User" %&gt; &lt;% User user = (User)request.getAttribute("user"); %&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;result&gt; &lt;status&gt;ok&lt;/status&gt; &lt;user_name&gt;&lt;%= user.getEmail() %&gt;&lt;/user_name&gt; &lt;/result&gt; </code></pre> <p>logged_out.jsp:</p> <pre><code>&lt;%@ page import="com.google.appengine.api.users.User" %&gt; &lt;% User user = (User)request.getAttribute("user"); %&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;result&gt; &lt;status&gt;error&lt;/status&gt; &lt;message&gt;not logged in&lt;/message&gt; &lt;/result&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload