javadev123-

This is what we tend to do to diagnose 2LO issues.  YMMV:

1. Start by creating a new java mini-project that has a main class with main 
method and all required gdata libraries and dependencies.
2. Grab our domains 2LO key/secret pair for testing.  This rules out scope 
issues.  If you are a domain admin of a GApps domain, you can grab the token 
pair here:  https://www.google.com/a/cpanel/[YOUR_DOMAIN.COM]/SetupOAuth
3. That key/secret pair should your admin account 2LO access to every feed 
available to your domain (Calendar, Contacts, Docs, etc.).
4. Using that pair, construct a new ContactsService like so:

ContactsService service = new ContactsService(APPLICATION_NAME);
         service.useSsl();
        GoogleOAuthParameters parameters = new GoogleOAuthParameters();
        parameters.setOAuthType(OAuthType.TWO_LEGGED_OAUTH);
        parameters.setOAuthConsumerKey(CONSUMER_KEY);
        parameters.setOAuthConsumerSecret(CONSUMER_SECRET);
        OAuthHmacSha1Signer signer = new OAuthHmacSha1Signer();
       service.setOAuthCredentials(parameters, signer);

5. Attempt a quick call to your accounts contacts:

ContactFeed resultFeed = service.getFeed(new 
URL("https://www.google.com/m8/feeds/contacts/"+your_email+"/full?xoauth_requestor_id="+your_email),
 
ContactFeed.class);

6. Do the same for calendars.
7. If you've gotten here, your code is solid.
8. To get your applications OAuth key/secret, register your application at 
https://www.google.com/accounts/ManageDomains
9. In your test code, replace your domain key/secret with your application 
key/secret and run.  This will likely fail.
10.  As an admin of your Google Apps domain, you need to explicitly 
authorize access by your application to the feeds you wish to access in your 
Control Panel.  You do that here: 
https://www.google.com/a/cpanel/cloudsherpas.com/ManageOauthClients
11. To authorize your application, fill in your application's key in the 
"Client Name" field, and fill in a comma-separated list of feeds you want 
the application to access in your domain.  Any scope you do not specify for 
that application key will not be authorized.  In your case, I believe you 
need to fill out: 
https://www.google.com/calendar/feeds/,https://www.google.com/m8/feeds/ 
12. After clicking the "Authorize" button, you should now have granted 
access by your application to your domain.
13. Rerun your test code.  It should now work if everything has been 
registered correctly.
14. Integrate that key/secret and code back into your application.

Note that the Google Apps MarketPlace does a lot of this auto-magically for 
you.  However, without the MarketPlace, every one of your customer domains 
will need to have an admin go through this same process to authorize your 
application.

Hope that helps,

-Steve Ziegler

-- 
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

Reply via email to