Hi Neha,

The UserService is a Google App Engine service, so I'd recommend you to ask
the same question in the App Engine forum:

http://code.google.com/appengine/community.html

Thanks
Claudio

On Fri, Jul 8, 2011 at 5:48 AM, 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 : " +
> GWT.getHostPageBaseURL());
>         } catch (OAuthRequestException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>
>
>     }
> }
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Apps Domain Information and Management APIs" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-apps-mgmt-apis/-/iY4b133XUZAJ.
> 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-apps-mgmt-apis?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Apps Domain Information and Management APIs" 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-apps-mgmt-apis?hl=en.

Reply via email to