簡體   English   中英

登錄問題,userService,丟失的會話-Google App Angine

[英]Problem with login ,userService , lost session - google app angine

我正在創建我的應用程序,我想將其與Google帳戶集成,但遇到以下問題:

我想授權用戶並返回此頁面,然后共享Google日歷中的一些數據。 所以這是我創建登錄URL(index.jsp)的代碼片段

boolean b= true;
UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();

if(user!=null){
%>
              <p>Hello, <%= user.getNickname() %>  </p>
<%
                                }

  try
                {singleUseToken AuthSubUtil.getTokenFromReply(request.getQueryString());

                }catch (NullPointerException e)
                {

        String nextUrl = Settings.SERVER_ADDRESS;
        String scope ="http://www.google.com/calendar/feeds/";

        String login=AuthSubUtil.getRequestUrl(nextUrl, scope, false, true);

%>
  <p>"App needs access to your Google Calendar account to read your Calendar feed. To authorize MyApp to access your account
  <a href="<%=userService.createLoginURL(login)  %>">log in to your account</a>.)</p>
<%
b=false;
   }

   if (b== true){

        CalendarService myService=null;   
                try{    
                    sessionToken = AuthSubUtil.exchangeForSessionToken(URLDecoder.decode(singleUseToken, "UTF-8"), null);
                }
                catch(NullPointerException e)
                {

                %>
                        <p><%=e %> </p>
<%
                    }
CalendarService myService = new CalendarService("google-ExampleApp-v1.0");
                    myService.setAuthSubToken(sessionToken);
                    ...

然后,我創建了authSubUrl並將其傳遞給UserService來創建第二個重定向,但是盡管已登錄,但UserService.getCurrentUser()返回null。 第二個問題是會話丟失-當我轉到其他.jsp頁面時,我從帳戶中注銷。

請幫忙

確保已在應用程序的appengine-web.xml中配置了啟用會話的屬性

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
   <application>myapp</application>
   <version>01</version>
   <ssl-enabled>true</ssl-enabled>  
   <sessions-enabled>true</sessions-enabled> <!- <<<<  Make sure you have this ->
</appengine-web-app>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM