ClientCredentials.CLIENT_SECRET,
code,
ClientCredentials.REDIRECT_URI).execute();
- PersistentStore credentialStore =
- new PersistentStore(prefs);
- credentialStore.write(accessTokenResponse);
+ PersistentStore store = new PersistentStore(prefs);
+ store.writeTokens(accessTokenResponse);
finish();
} else if (url.indexOf("error=")!=-1) {
- new PersistentStore(prefs).clear();
+ new PersistentStore(prefs).clearTokens();
finish();
}
} catch (IOException e) {
httpTransport = AndroidHttp.newCompatibleTransport();
jsonFactory = new JacksonFactory();
- AccessTokenResponse token = store.read();
+ AccessTokenResponse token = store.readTokens();
Log.v(TAG, "tokens - access: \"" + token.accessToken +
"\", refresh: \"" + token.refreshToken +
"\", client_id: \"" + ClientCredentials.CLIENT_ID +
this.prefs = prefs;
}
- public AccessTokenResponse read() {
+ public AccessTokenResponse readTokens() {
AccessTokenResponse accessTokenResponse = new AccessTokenResponse();
accessTokenResponse.accessToken = prefs.getString(ACCESS_TOKEN, "");
accessTokenResponse.expiresIn = prefs.getLong(EXPIRES_IN, 0);
return accessTokenResponse;
}
- public void write(AccessTokenResponse accessTokenResponse) {
+ public void writeTokens(AccessTokenResponse accessTokenResponse) {
Editor editor = prefs.edit();
editor.putString(ACCESS_TOKEN,accessTokenResponse.accessToken);
editor.putLong(EXPIRES_IN,accessTokenResponse.expiresIn);
editor.commit();
}
- public void clear() {
+ public void clearTokens() {
Editor editor = prefs.edit();
editor.remove(ACCESS_TOKEN);
editor.remove(EXPIRES_IN);