Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: how do I authenticate to my google account and how can I get my GMail Tasks?
    text
    copied!<p>I am developing an Android app to connect to my Google Tasks and show them in a ListView. I tried to follow step by step some tutorial such as <a href="https://developers.google.com/google-apps/tasks/oauth-and-tasks-on-android" rel="nofollow">https://developers.google.com/google-apps/tasks/oauth-and-tasks-on-android</a> but none of those works. I tried to download the google-api-services-tasks-v1-1.1.0-beta.jar and all the jars inicated in that tutorial, and after importing all the necessary libraries it just didn't work, and when i try to get my tasks after the connection i just get nulls.</p> <p>I found out that i could use Oauth2.0 for the authentication and to access to the tasks API, to get my clientID ecc., so i created an account on the Google API's Console and created my OAuth clientID.</p> <p>After that I try to authenticate with this code</p> <pre><code>HttpTransport transport = new NetHttpTransport(); JacksonFactory jsonFactory = new JacksonFactory(); String clientId = "myID"; String clientSecret = "mySecret"; String redirectUrl = "https://localhost/oauth2callback"; Iterable&lt;String&gt; scope ="https://www.googleapis.com/auth/tasks"; String authorizationUrl = new GoogleAuthorizationCodeRequestUrl(clientId, redirectUrl, scope) .build(); String code="Code"; GoogleTokenResponse response = new GoogleAuthorizationCodeTokenRequest(transport, jsonFactory, clientId, clientSecret, code, redirectUrl).execute(); GoogleAccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource( response.getAccessToken(), transport, jsonFactory, clientId, clientSecret, response.getRefreshToken()); Tasks service = new Tasks(transport, jsonFactory, accessProtectedResource); AccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource(accessToken); Tasks service = new Tasks(transport, new JacksonFactory(), accessProtectedResource); service.accessKey="MyKey"; service.setApplicationName("GTasks"); </code></pre> <p>I don't get any error but after creating this service I tried to get my tasklists but nothing happened and i didn't get any result. When I tried to Log the content of the List of tasklists i just got an empty list "{}". I suspect that this could be because of the old version of the libraries that i found, but even when i tried to use the latest versions it didn't work and i got the same results. I'm really confused.</p> <p>Every tutorial I found recommends a different version of the libraries and a different strategy. I really don't know wich one should I follow.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload