From 3cb8a812c9319b78716c3be18295e5ed31b088a2 Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Tue, 15 Aug 2017 12:48:12 -0300 Subject: [PATCH] capture oidc invalid_grant error for invalidcredentials --- .../android/authentication/AuthenticationException.java | 2 +- .../authentication/AuthenticationExceptionTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/auth0/src/main/java/com/auth0/android/authentication/AuthenticationException.java b/auth0/src/main/java/com/auth0/android/authentication/AuthenticationException.java index 46c039a47..b9d2859d3 100644 --- a/auth0/src/main/java/com/auth0/android/authentication/AuthenticationException.java +++ b/auth0/src/main/java/com/auth0/android/authentication/AuthenticationException.java @@ -192,7 +192,7 @@ public boolean isRuleError() { /// When username and/or password used for authentication are invalid public boolean isInvalidCredentials() { - return "invalid_user_password".equals(code); + return "invalid_user_password".equals(code) || "invalid_grant".equals(code) && "Wrong email or password.".equals(description); } /// When authenticating with web-based authentication and the resource server denied access per OAuth2 spec diff --git a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java index b2806cf7b..063d6fb51 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java @@ -203,6 +203,14 @@ public void shouldHaveInvalidCredentials() throws Exception { assertThat(ex.isInvalidCredentials(), is(true)); } + @Test + public void shouldHaveOIDCInvalidCredentials() throws Exception { + values.put(CODE_KEY, "invalid_grant"); + values.put(ERROR_DESCRIPTION_KEY, "Wrong email or password."); + AuthenticationException ex = new AuthenticationException(values); + assertThat(ex.isInvalidCredentials(), is(true)); + } + @Test public void shouldHaveAccessDenied() throws Exception { values.put(CODE_KEY, "access_denied");