1
votes

I'm trying to add support for Google Tasks to my app -- specifically, the app should be able to add a new tasks.

I've spent most of this week trying to accomplish this without success. Specifically, I've not managed to get my app fully authorized to access the API. I've found 3-5 different tutorials or sets of documentation for how to do it:

Many of the above appear to contradict one another, or at least use different APIs whose overlap isn't immediately apparent to me. The closest I've come is via the sample code referenced in the first link above (http://bit.ly/UHTKNW). I can get that to compile and run, and even to request permission from the user to access Tasks, as expected. But it then fails with a 403 Forbidden "access not configured" exception. I'm presuming I need to supply an API Key and/or client secret, but the APIs used in the example don't appear to provide an obvious way to do that. I'm also not clear on whether I need to set up a signing certificate fingerprint to make this work, and if so how to go about doing that.

So I'm stuck, confused, and super-frustrated. Any help would be greatly appreciated.

Thanks. --Dave

2

2 Answers

3
votes

Those APIs have changed a lot, I can understand your frustration.

Check out the most recent sample application. It contains the instructions for setting up the API access and getting you started.

Basically, you just register your application in the API Console and your code doesn't have to deal with any API keys:

GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(context, TasksScopes.TASKS);
credential.setSelectedAccountName(accountName);

mService = new com.google.api.services.tasks.Tasks.Builder(new NetHttpTransport(), new GsonFactory(), credential)
        .setApplicationName("YourApplicationName").build();

The Task APIs may throw different Exceptions, e.g. when the user has to confirm your app's access. In the sample, the CommonAsyncTask deals with them.

0
votes

check my other answer Access youtube account with accountmanager

it's for the YouTube, but the difference is just a matter of passing the right "link" to the code. Hope it helps.