Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Capture OAuth token request error edge cases #984

Merged
merged 1 commit into from

2 participants

Danilo Ercoli Maxime Biais
Danilo Ercoli

Fix #983

Maxime Biais maxme self-assigned this
Maxime Biais
Owner

Tested :+1:

Maxime Biais maxme merged commit 77181b6 into from
Maxime Biais maxme deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2014
  1. Danilo Ercoli
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/org/wordpress/android/util/ToastUtils.java
16 src/org/wordpress/android/util/ToastUtils.java
View
@@ -58,10 +58,18 @@ public static void showToastOrAuthAlert(Context context, VolleyError error, Stri
JSONObject errorObj = VolleyUtils.volleyErrorToJSON(error);
if (errorObj != null) {
try {
- message = (String) errorObj.get("message");
- String error_code = (String) errorObj.get("error");
- if (error_code!=null && error_code.equals("invalid_token"))
- isInvalidTokenError = true;
+ if (errorObj.has("error_description")) { //OAuth token request error
+ //{"error_description":"Incorrect username or password.","error":"invalid_request"}
+ message = (String) errorObj.get("error_description");
+ String error_code = (String) errorObj.get("error");
+ if (error_code!=null && error_code.equals("invalid_request") && message.toLowerCase().contains("incorrect username or password"))
+ isInvalidTokenError = true;
+ } else {
+ message = (String) errorObj.get("message");
+ String error_code = (String) errorObj.get("error");
+ if (error_code!=null && error_code.equals("invalid_token"))
+ isInvalidTokenError = true;
+ }
} catch (JSONException e) {
AppLog.e(T.API, e);
}
Something went wrong with that request. Please try again.