Skip to content

Commit 8c0ceb0

Browse files
committed
Move bundle update outside of try block
1 parent 6582062 commit 8c0ceb0

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

app/src/main/java/com/github/mobile/accounts/AccountAuthenticator.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,25 @@ public Bundle getAuthToken(AccountAuthenticatorResponse response,
173173
OAuthService service = new OAuthService(client);
174174
List<String> scopes = Arrays.asList("repo", "user", "gist");
175175

176+
String authToken;
176177
try {
177-
String authToken = getAuthorization(service, scopes);
178+
authToken = getAuthorization(service, scopes);
178179
if (TextUtils.isEmpty(authToken))
179180
authToken = createAuthorization(service, scopes);
180-
181-
if (TextUtils.isEmpty(authToken))
182-
bundle.putParcelable(KEY_INTENT, createLoginIntent(response));
183-
else {
184-
bundle.putString(KEY_ACCOUNT_NAME, account.name);
185-
bundle.putString(KEY_ACCOUNT_TYPE, ACCOUNT_TYPE);
186-
bundle.putString(KEY_AUTHTOKEN, authToken);
187-
am.clearPassword(account);
188-
}
189-
return bundle;
190181
} catch (IOException e) {
191182
Log.e(TAG, "Authorization retrieval failed", e);
192183
throw new NetworkErrorException(e);
193184
}
185+
186+
if (TextUtils.isEmpty(authToken))
187+
bundle.putParcelable(KEY_INTENT, createLoginIntent(response));
188+
else {
189+
bundle.putString(KEY_ACCOUNT_NAME, account.name);
190+
bundle.putString(KEY_ACCOUNT_TYPE, ACCOUNT_TYPE);
191+
bundle.putString(KEY_AUTHTOKEN, authToken);
192+
am.clearPassword(account);
193+
}
194+
return bundle;
194195
}
195196

196197
@Override

0 commit comments

Comments
 (0)