diff --git a/android/src/main/java/io/fullstack/oauth/OAuthManagerFragmentController.java b/android/src/main/java/io/fullstack/oauth/OAuthManagerFragmentController.java index 5281699..f04d8b7 100644 --- a/android/src/main/java/io/fullstack/oauth/OAuthManagerFragmentController.java +++ b/android/src/main/java/io/fullstack/oauth/OAuthManagerFragmentController.java @@ -10,6 +10,7 @@ import com.facebook.react.bridge.ReactContext; import com.github.scribejava.core.exceptions.OAuthConnectionException; +import com.github.scribejava.core.model.OAuth2AccessTokenErrorResponse; import com.github.scribejava.core.model.OAuth1AccessToken; import com.github.scribejava.core.model.OAuth1RequestToken; import com.github.scribejava.core.model.OAuth2AccessToken; @@ -367,6 +368,11 @@ protected OAuth2AccessToken doInBackground(Void... params) { Log.e(TAG, "OAuth connection exception: " + ex.getMessage()); ex.printStackTrace(); return null; + } catch (OAuth2AccessTokenErrorResponse ex) + { + Log.e(TAG, "Failed to extract access token: " + ex.getMessage()); + mCtrl.onError(-1, ex.getMessage(), "Failed to extract access token."); + return null; } catch (IOException ex) { Log.e(TAG, "An exception occurred getRequestToken: " + ex.getMessage()); ex.printStackTrace(); diff --git a/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java b/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java index 35777a4..8c4aff5 100644 --- a/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java +++ b/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java @@ -120,6 +120,18 @@ public void onRequestTokenError(final Exception ex) { Log.e(TAG, "Exception with request token: " + ex.getMessage()); _credentialsStore.delete(providerName); _credentialsStore.commit(); + + WritableMap error = Arguments.createMap(); + error.putString("message", ex.getMessage()); + + // In an invalid client situation we will get two errors, first for the invalid client, and second for the null access token + // we really want to report the invalid client error because it provides better feedback + try { + callback.invoke(error); + } catch (Exception e2) + { + Log.e(TAG, "exception with request: callback failed: " + e2.getMessage() ); + } } public void onOAuth1AccessToken(final OAuth1AccessToken accessToken) { _credentialsStore.store(providerName, accessToken);