Fix authentication issue

This commit is contained in:
Thomas 2022-06-22 15:35:08 +02:00
parent 5ddc756440
commit 4c375cfe4a

View file

@ -52,6 +52,7 @@ public class LoginActivity extends BaseActivity {
private boolean requestedAdmin; private boolean requestedAdmin;
private void manageItent(Intent intent) { private void manageItent(Intent intent) {
if (intent != null && intent.getData() != null && intent.getData().toString().contains(REDIRECT_CONTENT_WEB + "?code=")) { if (intent != null && intent.getData() != null && intent.getData().toString().contains(REDIRECT_CONTENT_WEB + "?code=")) {
String url = intent.getData().toString(); String url = intent.getData().toString();
Matcher matcher = Helper.codePattern.matcher(url); Matcher matcher = Helper.codePattern.matcher(url);
@ -61,9 +62,7 @@ public class LoginActivity extends BaseActivity {
} }
String code = matcher.group(1); String code = matcher.group(1);
OauthVM oauthVM = new ViewModelProvider(LoginActivity.this).get(OauthVM.class); OauthVM oauthVM = new ViewModelProvider(LoginActivity.this).get(OauthVM.class);
//We are dealing with a Mastodon API //We are dealing with a Mastodon API
if (apiLogin == Account.API.MASTODON) {
//API call to get the user token //API call to get the user token
String scope = requestedAdmin ? Helper.OAUTH_SCOPES_ADMIN : Helper.OAUTH_SCOPES; String scope = requestedAdmin ? Helper.OAUTH_SCOPES_ADMIN : Helper.OAUTH_SCOPES;
oauthVM.createToken(currentInstanceLogin, "authorization_code", client_idLogin, client_secretLogin, Helper.REDIRECT_CONTENT_WEB, scope, code) oauthVM.createToken(currentInstanceLogin, "authorization_code", client_idLogin, client_secretLogin, Helper.REDIRECT_CONTENT_WEB, scope, code)
@ -94,7 +93,6 @@ public class LoginActivity extends BaseActivity {
}); });
} }
} }
}
@Override @Override