Skip to content

Commit

Permalink
Throw DescopeException when browser fails to launch (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
itaihanski authored Oct 1, 2024
1 parent 5c19694 commit 3f99efb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ internal class DescopeClient(internal val config: DescopeConfig) : HttpClient(co
body = mapOf(
"provider" to provider.name,
"loginOptions" to options?.toMap(),
"implicit" to true,
),
)

Expand Down
8 changes: 6 additions & 2 deletions descopesdk/src/main/java/com/descope/internal/routes/Flow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ internal class Flow(
}

private fun launchUri(context: Context, uri: Uri) {
val customTabsIntent = flowPresentation?.createCustomTabsIntent(context) ?: defaultCustomTabIntent()
customTabsIntent.launchUrl(context, uri)
try {
val customTabsIntent = flowPresentation?.createCustomTabsIntent(context) ?: defaultCustomTabIntent()
customTabsIntent.launchUrl(context, uri)
} catch (e: Exception) {
throw DescopeException.browserError.with(cause = e)
}
}

}
Expand Down
4 changes: 2 additions & 2 deletions descopesdk/src/main/java/com/descope/sdk/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,13 @@ interface DescopeOAuth {
* the user sign in with the Google account they're already using on their device.
*
* If you haven't already configured your app to support Sign in with Google you'll
* probably need to set up your [Google APIs console project](https://developers.google.com/identity/one-tap/android/get-started#api-console)
* probably need to set up your [Google APIs console project](https://developer.android.com/identity/sign-in/credential-manager-siwg#set-google)
* for this. You should also configure an OAuth provider for Google in the in the [Descope console](https://app.descope.com/settings/authentication/social),
* with its `Grant Type` set to `Implicit`. Also note that the `Client ID` and
* `Client Secret` should be set to the values of your `Web application` OAuth client,
* rather than those from the `Android` OAuth client.
*
* For more details about configuring your app see the [Credential Manager documentation](https://developer.android.com/training/sign-in/credential-manager).
* For more details about configuring your app see the [Credential Manager documentation](https://developer.android.com/identity/sign-in/credential-manager).
*
* Note: This is an asynchronous operation that performs network requests before and
* after displaying the modal authentication view. It is thus recommended to switch the
Expand Down
2 changes: 1 addition & 1 deletion descopesdk/src/main/java/com/descope/sdk/Sdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ class DescopeSdk(context: Context, projectId: String, configure: DescopeConfig.(
const val name = "DescopeAndroid"

/** The Descope SDK version */
const val version = "0.11.1"
const val version = "0.11.2"
}
}
1 change: 1 addition & 0 deletions descopesdk/src/main/java/com/descope/types/Error.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class DescopeException(
* offline or the network request timing out.
*/
val networkError = DescopeException(code = "K010001", desc = "Network error")
val browserError = DescopeException(code = "K010002", desc = "Unable to launch browser")

val badRequest = DescopeException(code = "E011001", desc = API_DESC)
val missingArguments = DescopeException(code = "E011002", desc = API_DESC)
Expand Down

0 comments on commit 3f99efb

Please sign in to comment.