may be it is correct - for gmail accounts.

On Jul 11, 10:16 pm, Neha Chandra <[email protected]> wrote:
> Hi,
>
> I am trying to retreive Domain name but the code i have written it returning
> gmail.com.
>
> package com;
>
> import java.io.IOException;
> import com.google.appengine.api.
> users.UserService;
> import com.google.appengine.api.users.UserServiceFactory;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import com.google.appengine.api.oauth.OAuthRequestException;
> import com.google.appengine.api.oauth.OAuthService;
> import com.google.appengine.api.oauth.OAuthServiceFactory;
> import com.google.appengine.api.users.User;
> import com.google.gwt.core.client.GWT;
>
> @SuppressWarnings("serial")
> public class GetDomainServlet extends HttpServlet {
>     public void doGet(HttpServletRequest req, HttpServletResponse resp)
>             throws IOException {
>         resp.setContentType("text/plain");
>         resp.getWriter().println("Hello, world");
>         resp.getWriter().println("Hllo");
>
>          UserService userService = UserServiceFactory.getUserService();
>
>             String thisURL = req.getRequestURI();
>
>         if (req.getUserPrincipal() != null) {
>             resp.getWriter().println("In if");
>             resp.getWriter().println("<p>Hello, " +
>                     req.getAuthType());
>         } else {
>             resp.getWriter().println("In else");
>             resp.getWriter().println("<p>Please <a href=\"" +
>                                          userService.createLoginURL(thisURL)
> +
>                                          "\">sign in</a>.</p>");
>             resp.getWriter().println("<p>Hello, " +
>                     req.getQueryString());
>         }
>
>         OAuthService oauth = OAuthServiceFactory.getOAuthService();
>         try {
>             User user = oauth.getCurrentUser();
>             resp.getWriter().println("<br/>Get Current Domain : " +
> user.getAuthDomain());
>         } catch (OAuthRequestException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>
>     }
>
>
>
>
>
>
>
> }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to