You do not need. Just call GoogleAuthUtil.getToken () before each HTTP session, and GoogleAuthUtil will make sure you get one that works by updating if necessary.
EDITED: Oh well, he does it on the server. Here is some Java code that uses the update token:
String data = "refresh_token=" + mRefreshToken + "&client_id=" + Constants.WEB_CLIENT_ID + "&client_secret=" + Constants.WEB_CLIENT_SECRET + "&grant_type=refresh_token"; byte[] body = data.getBytes(); URL url = new URL(Constants.GOOGLE_TOKEN_ENDPOINT); conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setFixedLengthStreamingMode(body.length); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); conn.getOutputStream().write(body); body = XAuth.readStream(conn.getInputStream()); JSONObject json = new JSONObject(new String(body)); String accessToken = json.optString("access_token"); if (accessToken == null) { throw new Exception("Refresh token yielded no access token"); }
source share