Hello Maxim, First, please have a look at those links as there are some examples in Java and 2-legged OAuth: * http://code.google.com/apis/gdata/docs/auth/oauth.html#2LeggedOAuth * http://code.google.com/googleapps/domain/articles/unshare-profiles-using-batch.html
After looking at the code, I don't see anything weird, but it is not impossible that I might have missed something. I will give it another run. In the meantime, this error can be thrown when the consumer key and secret don't have the associated scopes. Not being familiar with how marketplace applications manifests are handled, I won't be able to tell you if there is anything wrong with that. However, if you have a test domain, you would be able to try by either: * allowing access to all APIs with the domain's consumer key and secret. * specify the individual https://www.google.com/m8/feeds scope in the "Manage third party OAuth Client access" pane (under "Advanced Tools"). Doing that will help you figure out if the error is coming from your code or your manifest file. Additionally, you should be able to test your consumer key and secret on OAuth Playground<http://googlecodesamples.com/oauth_playground/>(choose HMAC-SHA1 as the signature method). Best, Alain On Tue, Oct 11, 2011 at 10:25 AM, Maxim Oleinyk <[email protected]>wrote: > Hi, Alain > > Thank you for reply. Here's my code: > > My query that provides user list: > > public class UserProfileQuery implements Query<UserPrincipal, > List<GoogleUser>> { > > @Inject > private TwoLeggedHmacAuthenticatorFact**ory authenticatorFactory; > > private String domainAdminEmail; > > @Override > public List<GoogleUser> fetch(UserPrincipal params) { > String authDomain = params.getAuthDomain(); > // newAuthenticator method just creates new instance of > TwoLeggedHmacAuthenticator > // with dev or production environment properties of key and secret > TwoLeggedHmacAuthenticator twoLeggedHmacAuthenticator = > authenticatorFactory.**newAuthenticator(authDomain); > // This factory creates new instance of RetrieveAllProfilesCommand > class > ProfilesCommandFactory profilesCommandFactory = new > ProfilesCommandFactory(**twoLeggedHmacAuthenticator); > RetrieveAllProfilesCommand command = profilesCommandFactory.** > newRetrieveAllProfilesCommand( > new RetrieveAllProfilesCommand.**CommandData(authDomain, > domainAdminEmail)); > return command.execute(); > } > > public void setDomainAdminEmail(String domainAdminEmail) { > this.domainAdminEmail = domainAdminEmail; > } > } > > public class TwoLeggedHmacAuthenticator implements GoogleAuthenticator{ > private final String marketPlaceConsumerKey; > private final String marketPlaceConsumerSecret; > private final String domain; > > /*package*/ TwoLeggedHmacAuthenticator(**String domain, String > marketPlaceConsumerKey, String marketPlaceConsumerSecret){ > this.domain = domain; > this.marketPlaceConsumerKey = marketPlaceConsumerKey; > this.marketPlaceConsumerSecret = marketPlaceConsumerSecret; > } > > @Override > public void initWithCredentials(**GoogleService googleService) throws > GdataAuthException { > GoogleOAuthParameters oauthParameters = new > GoogleOAuthParameters(); > oauthParameters.**setOAuthConsumerKey(**marketPlaceConsumerKey); > oauthParameters.**setOAuthConsumerSecret(** > marketPlaceConsumerSecret); > oauthParameters.setOAuthType(**OAuthType.TWO_LEGGED_OAUTH); > try { > googleService.**setOAuthCredentials(**oauthParameters, new > OAuthHmacSha1Signer()); > } catch (OAuthException e) { > throw new GdataAuthException(e); > } > } > > @Override > public String getDomain() { > return this.domain; > } > } > > public class RetrieveAllProfilesCommand extends AbstractGoogleCommand<** > RetrieveAllProfilesCommand.**CommandData, List<GoogleUser>, > ContactsService> { > > private static final String URL_FORMAT_PROFILES = " > https://www.google.com/m8/**feeds/profiles/domain/%s/full?** > xoauth_requestor_id=%s"; > > public RetrieveAllProfilesCommand(**ContactsService s, CommandData > param) { > super(s, param); > } > > @Override > protected List<GoogleUser> doExecute(CommandData cmdData) throws > IOException, ServiceException { > URL feedUrl = new URL(format(URL_FORMAT_**PROFILES, > cmdData.getDomain(), cmdData.getDomainAdminEmail())**); > // exception throws here after getFeed invokation > ContactFeed contactFeed = getGoogleService().getFeed(**feedUrl, > ContactFeed.class); > return parseEntries(contactFeed.**getEntries()); > } > > private List<GoogleUser> parseEntries(List<**ContactEntry> entries) { > // ... > } > > public static class CommandData { > // ... > } > } > > [AbstractGoogleCommand] > > public abstract class AbstractGoogleCommand<P, R, S extends GoogleService> > { > protected static final String APPS_FEEDS_URL_BASE = " > https://apps-apis.google.com/**a/feeds/<https://apps-apis.google.com/a/feeds/> > "; > public static final String APPLICATION_NAME = "my-app-name"; > > private Logger logger = Logger.getLogger(getClass().**getName()); > > private S googleService; > private P param; > > protected AbstractGoogleCommand(S s, @Nullable P param) { > this.googleService = s; > this.param = param; > } > > public final R execute() { > try { > return doExecute(param); > } catch (AuthenticationException e) { > logger.log(Level.SEVERE, e.getAuthHeader()); > logger.log(Level.SEVERE, e.getDebugInfo()); > logger.log(Level.SEVERE, e.getDomainName()); > logger.log(Level.SEVERE, e.getMessage()); > throw new GoogleAuthenticationException(**e.getMessage(), e); > } catch (IOException e) { > logger.log(Level.SEVERE, e.getMessage(), e); > throw new GdataCommandExecutionFailed(e)**; > } catch (ServiceException e) { > logger.log(Level.SEVERE, e.getMessage(), e); > throw new GdataCommandExecutionFailed(e)**; > } > } > > protected abstract R doExecute(P cmdData) throws IOException, > ServiceException; > > protected S getGoogleService() { > return googleService; > } > } > > Thank you Alain for your help. > > Best regards, > Maxim > > -- > You received this message because you are subscribed to the Google > Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html > -- Alain Vongsouvanh | Developer Programs Engineer -- You received this message because you are subscribed to the Google Groups "Google Contacts, Shared Contacts and User Profiles 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://code.google.com/apis/contacts/community/forum.html
