0

I'm very new with Glass and I follow this link https://developers.google.com/glass/develop/mirror/quickstart/java to deploy project to Google app engine.

Now everything works, but every time when I close browser then open browser and access my site(mysite.appspot.com), it's require user permission again and again.

Please help me to solve it, thank you very much.

Sniper
  • 5
  • 3

1 Answers1

0

This is because the Java Quickstart demo utilizes sessions to identify users. One of the reasons a session's lifetime ends is due to a user quitting the browser. Therefore when you close and then reopen a browser, the web app has no way to identify you since the session has ended.

The code that checks for a user's identity in sessions is in AuthFilter.java of the Quickstart demo project:

if (AuthUtil.getUserId(httpRequest) == null
      || AuthUtil.getCredential(AuthUtil.getUserId(httpRequest)) == null
      || AuthUtil.getCredential(AuthUtil.getUserId(httpRequest)).getAccessToken() == null) {
    // redirect to auth flow
    httpResponse.sendRedirect(WebUtil.buildUrl(httpRequest, "/oauth2callback"));
    return;
  }

If the servlet cannot find the user ID (as is the case when the user ID is no longer saved in a session), it runs the user through the authentication process again that starts with the httpResponse.sendRedirect call in the code above.

Koh
  • 1,570
  • 1
  • 8
  • 6