mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-14 06:22:50 +01:00
Make OAuth2 API change: https://www.reddit.com/r/redditdev/comments/kvzaot/oauth2_api_changes_upcoming/
This commit is contained in:
parent
569283ea93
commit
e19dd8c31f
@ -69,9 +69,10 @@ class AccessTokenAuthenticator implements Authenticator {
|
|||||||
try {
|
try {
|
||||||
retrofit2.Response<String> response = accessTokenCall.execute();
|
retrofit2.Response<String> response = accessTokenCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
JSONObject jsonObject = new JSONObject((String) response.body());
|
JSONObject jsonObject = new JSONObject(response.body());
|
||||||
String newAccessToken = jsonObject.getString(APIUtils.ACCESS_TOKEN_KEY);
|
String newAccessToken = jsonObject.getString(APIUtils.ACCESS_TOKEN_KEY);
|
||||||
mRedditDataRoomDatabase.accountDao().changeAccessToken(account.getUsername(), newAccessToken);
|
String newRefreshToken = jsonObject.getString(APIUtils.REFRESH_TOKEN_KEY);
|
||||||
|
mRedditDataRoomDatabase.accountDao().updateAccessTokenAndRefreshToken(account.getUsername(), newAccessToken, newRefreshToken);
|
||||||
|
|
||||||
return newAccessToken;
|
return newAccessToken;
|
||||||
}
|
}
|
||||||
|
@ -245,11 +245,12 @@ public class PullNotificationWorker extends Worker {
|
|||||||
|
|
||||||
Call<String> accessTokenCall = api.getAccessToken(APIUtils.getHttpBasicAuthHeader(), params);
|
Call<String> accessTokenCall = api.getAccessToken(APIUtils.getHttpBasicAuthHeader(), params);
|
||||||
try {
|
try {
|
||||||
Response response = accessTokenCall.execute();
|
Response<String> response = accessTokenCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
JSONObject jsonObject = new JSONObject(response.body().toString());
|
JSONObject jsonObject = new JSONObject(response.body());
|
||||||
String newAccessToken = jsonObject.getString(APIUtils.ACCESS_TOKEN_KEY);
|
String newAccessToken = jsonObject.getString(APIUtils.ACCESS_TOKEN_KEY);
|
||||||
mRedditDataRoomDatabase.accountDao().changeAccessToken(account.getUsername(), newAccessToken);
|
String newRefreshToken = jsonObject.getString(APIUtils.REFRESH_TOKEN_KEY);
|
||||||
|
mRedditDataRoomDatabase.accountDao().updateAccessTokenAndRefreshToken(account.getUsername(), newAccessToken, newRefreshToken);
|
||||||
return newAccessToken;
|
return newAccessToken;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -50,6 +50,6 @@ public interface AccountDao {
|
|||||||
@Query("UPDATE accounts SET is_current_user = 1 WHERE username = :username")
|
@Query("UPDATE accounts SET is_current_user = 1 WHERE username = :username")
|
||||||
void markAccountCurrent(String username);
|
void markAccountCurrent(String username);
|
||||||
|
|
||||||
@Query("UPDATE accounts SET access_token = :accessToken WHERE username = :username")
|
@Query("UPDATE accounts SET access_token = :accessToken, refresh_token = :refreshToken WHERE username = :username")
|
||||||
void changeAccessToken(String username, String accessToken);
|
void updateAccessTokenAndRefreshToken(String username, String accessToken, String refreshToken);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
app:summary="@string/restart_app_see_changes"
|
app:summary="@string/restart_app_see_changes"
|
||||||
app:enabled="false" />
|
app:enabled="false" />
|
||||||
|
|
||||||
|
<PreferenceCategory />
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:defaultValue="1"
|
app:defaultValue="1"
|
||||||
app:entries="@array/settings_number_of_columns_in_post_feed"
|
app:entries="@array/settings_number_of_columns_in_post_feed"
|
||||||
|
Loading…
Reference in New Issue
Block a user