views:

26

answers:

1

Hi

I'm creating my application and i want integrate it with google account and I have following problems:

I want to authorize the user and get back to this pages and after share some data from google calendar. So this is my code snippet to create the login 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);
                    ...

And I create the authSubUrl and pass it to the UserService to create the second redirect, but UserService.getCurrentUser() returns null although I'm logged. The second problems it's lost session - when I go to the other .jsp pages I'm log out from my account.

Please help

A: 

Make sure you have configured the sessions-enabled property in your application's appengine-web.xml

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"&gt;
   <application>myapp</application>
   <version>01</version>
   <ssl-enabled>true</ssl-enabled>  
   <sessions-enabled>true</sessions-enabled> <!- <<<<  Make sure you have this ->
</appengine-web-app>
Gopi
I added this, but it didn't help. Maybe the code in index.jsp it's wrong?
qazah