I have a gae application at google marketplace.
Where i need to get the domain users with the help to cosumer ke and secret.
Here is my code.
com.google.gdata.client.appsforyourdomain.UserService guserService =
new com.google.gdata.client.appsforyourdomain.UserService(
"test");
String consumerKey = appProperties.getConsumerKey();
String consumerSecret = appProperties.getConsumerKeySecret();
String urlEscopo =
"https://apps-apis.google.com/a/feeds/user/#readonly";
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(consumerKey);
oauthParameters.setOAuthConsumerSecret(consumerSecret);
oauthParameters.setOAuthType(OAuthType.TWO_LEGGED_OAUTH);
oauthParameters.setScope(urlEscopo);
try {
guserService.setOAuthCredentials(oauthParameters,
new OAuthHmacSha1Signer());
guserService.setReadTimeout(20000);
guserService.setConnectTimeout(20000);
} catch (OAuthException e) {
e.printStackTrace();
throw new ServletException("Unable to initialize service",
e);
}
final String APPS_FEEDS_URL_BASE =
"https://apps-apis.google.com/a/feeds/";
final String SERVICE_VERSION = "2.0";
String domainUrlBase = APPS_FEEDS_URL_BASE +
CommonWebUtil.getDomain(getCurrentUser(
request).getEmail()) + "/";
URL retrieveUrl = new URL(domainUrlBase + "user/" +
SERVICE_VERSION);
UserFeed genericFeed = new UserFeed();
Link nextLink = null;
do {
try {
System.out.println("retrieveUrl"+retrieveUrl);
genericFeed = guserService.getFeed(retrieveUrl, UserFeed.class);
genericFeed.getEntries().addAll(genericFeed.getEntries());
nextLink = genericFeed.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
}
} catch (AppsForYourDomainException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} while (nextLink != null);
if (genericFeed != null && genericFeed.getEntries() != null &&
!genericFeed.getEntries().isEmpty()) {
for (UserEntry genericEntry : genericFeed.getEntries()) {
System.out.println(genericEntry.getLogin().getUserName());
// appUsers.add(appUser);
}
}
And the eror I am getting is as follows:
WARNING: Unable to respond to any of these challenges:
{googlelogin=GoogleLogin
realm="http://www.google.com/accounts/ClientLogin", service="apps"}
com.google.gdata.util.AuthenticationException: OK
<HTML>
<HEAD>
<TITLE>Unknown authorization header</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unknown authorization header</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
at
com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:596)
at
com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at
com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:550)
at
com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at
com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:998)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:631)
at com.google.gdata.client.Service.getFeed(Service.java:1017)
at
com.google.gdata.client.appsforyourdomain.AppsForYourDomainService.getFeed(AppsForYourDomainService.java:137)
at
com.netkiller.web.sharedcontacts.SharedContactsController.handleRequest(SharedContactsController.java:243)
at
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at
com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at
com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
And when i added "[email protected]" to my feed url It gave
and error with message "invalid Authsub scope".
I wasted more than a day solving the problem. Please help me fixing this
issue.
Regards,
Saurab parakh
--
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/-/P94DYW26k2IJ.
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.