Skip to content

Commit

Permalink
Fix method for authentication token generation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreroman committed Feb 7, 2013
1 parent 81df962 commit fd9c7f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/org/pixmob/httpclient/AbstractAccountAuthenticator.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public final Account getAccount() {
* if authentication failed (network error, bad credentials,
* etc...)
*/
protected final String generateAuthToken() throws HttpClientException {
protected final String generateAuthToken(String authTokenType) throws HttpClientException {
// Get an authentication token from the AccountManager:
// this call is asynchronous, as the user may not respond immediately.
final AccountManager am = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
Expand All @@ -86,9 +86,9 @@ protected final String generateAuthToken() throws HttpClientException {
// The AccountManager API for authentication token is different before
// Ice Cream Sandwich.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
authResultFuture = GetTokenLegacy.INSTANCE.get(am, account);
authResultFuture = GetTokenLegacy.INSTANCE.get(am, account, authTokenType);
} else {
authResultFuture = GetTokenICS.INSTANCE.get(am, account);
authResultFuture = GetTokenICS.INSTANCE.get(am, account, authTokenType);
}

final Bundle authResult;
Expand Down Expand Up @@ -124,17 +124,17 @@ private static class GetTokenLegacy {
public static final GetTokenLegacy INSTANCE = new GetTokenLegacy();

@SuppressWarnings("deprecation")
public AccountManagerFuture<Bundle> get(AccountManager am, Account account) {
return am.getAuthToken(account, "ah", false, null, null);
public AccountManagerFuture<Bundle> get(AccountManager am, Account account, String authTokenType) {
return am.getAuthToken(account, authTokenType, false, null, null);
}
}

private static class GetTokenICS {
public static final GetTokenICS INSTANCE = new GetTokenICS();

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public AccountManagerFuture<Bundle> get(AccountManager am, Account account) {
return am.getAuthToken(account, "ah", null, false, null, null);
public AccountManagerFuture<Bundle> get(AccountManager am, Account account, String authTokenType) {
return am.getAuthToken(account, authTokenType, null, false, null, null);
}
}
}
4 changes: 4 additions & 0 deletions src/org/pixmob/httpclient/GoogleAppEngineAuthenticator.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ private static String urlEncode(String str) {
return encoded;
}

private String generateAuthToken() throws HttpClientException {
return generateAuthToken("ah");
}

@Override
public void onRequest(HttpURLConnection conn) throws Exception {
if (authCookieValue == null) {
Expand Down

0 comments on commit fd9c7f3

Please sign in to comment.