Skip to content

Commit

Permalink
Merge pull request #443 from FormidableLabs/feature/handle-unsuitable…
Browse files Browse the repository at this point in the history
…-browser-android

Feature/handle unsuitable browser android
  • Loading branch information
Kadi Kraman authored Jan 10, 2020
2 parents 44390ae + 06d70af commit e2328f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,13 @@ try {
}
```
See example configurations for different providers below.
## Error messages
- `service_configuration_fetch_error` - could not fetch the service configuration
- `authentication_failed` - user authentication failed
- `token_refresh_failed` - could not exchange the refresh token for a new JWT
- `registration_failed` - could not register
- `browser_not_found` (Android only) - no suitable browser installed
#### Note about client secrets
Expand Down
5 changes: 5 additions & 0 deletions android/src/main/java/com/rnappauth/RNAppAuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.content.ActivityNotFoundException;
import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsCallback;
import androidx.browser.customtabs.CustomTabsClient;
Expand Down Expand Up @@ -245,6 +246,8 @@ public void authorize(
usePKCE,
additionalParametersMap
);
} catch (ActivityNotFoundException e) {
promise.reject("browser_not_found", e.getMessage());
} catch (Exception e) {
promise.reject("authentication_failed", e.getMessage());
}
Expand Down Expand Up @@ -327,6 +330,8 @@ public void refresh(
clientSecret,
promise
);
} catch (ActivityNotFoundException e) {
promise.reject("browser_not_found", e.getMessage());
} catch (Exception e) {
promise.reject("token_refresh_failed", e.getMessage());
}
Expand Down

0 comments on commit e2328f5

Please sign in to comment.