Trying to refresh a token to access Google Contacts where user has approved access_type=offline.
URL to request access: https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http://localhost:8181/servlet/?activity%3Dgc_oauth&response_type=code&scope=http://www.google.com/m8/feeds/&access_type=offline&approval_prompt=force This works and I get an access token that works for a while. At some point that token expires and I need to refresh. It appears that my refresh token is good (ya29.AHES6ZRhvyWAx4z_8_uJnBuI6tEELZqBDdh54Ti6ydvb5f0), but the access.getAccessToken() returns null after a call to access.refresh(). Here is the code: HttpTransport TRANSPORT = new NetHttpTransport(); JsonFactory JSON_FACTORY = new JacksonFactory(); GoogleAccessProtectedResource access = new GoogleAccessProtectedResource(parent.accessTokenGC, TRANSPORT, JSON_FACTORY, GCGlobals.clientID, GCGlobals.clientSecret, parent.refreshTokenGC); HttpRequestFactory rf = TRANSPORT.createRequestFactory(access); GenericUrl contactURL = new GenericUrl(GCGlobals.baseScope + "contacts/default/full?max-results=5000&alt=json"); HttpRequest req = rf.buildGetRequest(contactURL); GoogleHeaders header = new GoogleHeaders(); header.setContentType("application/json"); header.set("GData-Version", "3"); req.setHeaders(header); try { res = req.execute(); } catch (com.google.api.client.http.HttpResponseException ee) { // try to refresh the token try { System.out.println(ee.getMessage()); // prints 401 Token invalid - Invalid token: Stateless token expired access.refreshToken(); parent.accessTokenGC = access.getAccessToken(); // returns null thus I cannot proceed Any help greatly appreciated! -- 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
