summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2019-01-05 12:17:38 +0100
committerstom79 <tschneider.ac@gmail.com>2019-01-05 12:17:38 +0100
commiteefe1edc3b8cd924d0892a2d1aa53e3ce21ec558 (patch)
tree29316c3dbf0b5493d37eb3a372b3e5bc63e7a1af /app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java
parent7c298dcec0251af45df6fd028390816f5167d857 (diff)
Prepares db for storing information for refreshing the token #699
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java
index 71d170f76..38976996b 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java
@@ -120,12 +120,15 @@ public class LoginActivity extends BaseActivity {
try {
resobj = new JSONObject(response);
String token = resobj.get("access_token").toString();
+ String refresh_token = null;
+ if( resobj.has("refresh_token"))
+ refresh_token = resobj.get("access_token").toString();
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
editor.apply();
//Update the account with the token;
- new UpdateAccountInfoAsyncTask(LoginActivity.this, token, instance, peertube_instance.isChecked()?UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE:UpdateAccountInfoAsyncTask.SOCIAL.MASTODON).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new UpdateAccountInfoAsyncTask(LoginActivity.this, token, client_id, client_secret, refresh_token, instance, peertube_instance.isChecked()?UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE:UpdateAccountInfoAsyncTask.SOCIAL.MASTODON).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (JSONException ignored) {}
} catch (Exception ignored) {}
}}).start();
@@ -510,12 +513,15 @@ public class LoginActivity extends BaseActivity {
try {
resobj = new JSONObject(response);
String token = resobj.get("access_token").toString();
+ String refresh_token = null;
+ if( resobj.has("refresh_token"))
+ refresh_token = resobj.get("access_token").toString();
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
editor.apply();
//Update the account with the token;
- new UpdateAccountInfoAsyncTask(LoginActivity.this, token, instance, peertube_instance.isChecked()?UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE:UpdateAccountInfoAsyncTask.SOCIAL.MASTODON).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new UpdateAccountInfoAsyncTask(LoginActivity.this, token, client_id, client_secret, refresh_token, instance, peertube_instance.isChecked()?UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE:UpdateAccountInfoAsyncTask.SOCIAL.MASTODON).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (JSONException ignored) {ignored.printStackTrace();}
}
});