Retreive Domain Name of Google Apps Api

23 views
Skip to first unread message

Neha Chandra

unread,
Jul 8, 2011, 8:48:09 AM7/8/11
to google-app...@googlegroups.com
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();
        }
       

    }
}

Claudio Cherubino

unread,
Jul 11, 2011, 2:43:27 PM7/11/11
to google-app...@googlegroups.com
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:


Thanks
Claudio


--
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 google-app...@googlegroups.com.
To unsubscribe from this group, send email to google-apps-mgmt...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.

Reply all
Reply to author
Forward
0 new messages