Skip to content

Commit e2328f5

Browse files
author
Kadi Kraman
authored
Merge pull request #443 from FormidableLabs/feature/handle-unsuitable-browser-android
Feature/handle unsuitable browser android
2 parents 44390ae + 06d70af commit e2328f5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,13 @@ try {
390390
}
391391
```
392392
393-
See example configurations for different providers below.
393+
## Error messages
394+
395+
- `service_configuration_fetch_error` - could not fetch the service configuration
396+
- `authentication_failed` - user authentication failed
397+
- `token_refresh_failed` - could not exchange the refresh token for a new JWT
398+
- `registration_failed` - could not register
399+
- `browser_not_found` (Android only) - no suitable browser installed
394400
395401
#### Note about client secrets
396402

android/src/main/java/com/rnappauth/RNAppAuthModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.content.Intent;
88
import android.net.Uri;
99
import android.os.Bundle;
10+
import android.content.ActivityNotFoundException;
1011
import androidx.annotation.Nullable;
1112
import androidx.browser.customtabs.CustomTabsCallback;
1213
import androidx.browser.customtabs.CustomTabsClient;
@@ -245,6 +246,8 @@ public void authorize(
245246
usePKCE,
246247
additionalParametersMap
247248
);
249+
} catch (ActivityNotFoundException e) {
250+
promise.reject("browser_not_found", e.getMessage());
248251
} catch (Exception e) {
249252
promise.reject("authentication_failed", e.getMessage());
250253
}
@@ -327,6 +330,8 @@ public void refresh(
327330
clientSecret,
328331
promise
329332
);
333+
} catch (ActivityNotFoundException e) {
334+
promise.reject("browser_not_found", e.getMessage());
330335
} catch (Exception e) {
331336
promise.reject("token_refresh_failed", e.getMessage());
332337
}

0 commit comments

Comments
 (0)