---
title: Step 3. Authenticating with external IdPs
description: PingOne Android
component: orchsdks
page_id: orchsdks:davinci:use-cases/external-idp/android/03_authenticate_with_external_idps
canonical_url: https://developer.pingidentity.com/orchsdks/davinci/use-cases/external-idp/android/03_authenticate_with_external_idps.html
revdate: Tue, 25 Mar 2025 11:00:37 +0100
keywords: ["DaVinci", "Flows", "Tutorial", "Source Code", "Integration", "SDK", "Android"]
---

# Step 3. Authenticating with external IdPs

[icon: circle-check, set=far]PingOne [icon: android, set=fab]Android

Your app must handle the relevant node types your server returns when a user attempts to authenticate using an external IdP.

When encountering the `IdpCollector`, call `authorize()` to begin authentication with the external IdP:

```kotlin
var node = daVinci.start()

if (node is ContinueNode) {
    node.collectors.forEach { collector ->
        if (collector is IdpCollector) {
            val idp = collector
            val redirectUri = "myapp://callback".toUri()
            when (val result = idp.authorize(redirectUri)) {
                is Success -> {
                    // Authentication successful, proceed to the next step in the DaVinci flow
                    node = node.next()
                    // Process the next node
                }
                is Failure -> {
                    // Authentication failed, handle the error
                    val error: Throwable = result.error
                    // Log or display the error message
                }
            }
            return // Assuming only one IdpCollector per node
        }
    }
}
```

The `authorize()` method returns a `Success` result when authentication with the external IdP completes successfully. If not, it returns `Failure` and `Throwable` which shows the root cause of the issue.

```kotlin
val result = idp.authorize()

result.onSuccess {
    // Move to next Node
}
result.onFailure {
    it // The Throwable
}
```

The result resembles the following:

![An Android app with three external IdP options; Google, Apple, and Facebook.](../../../_images/social-sign-on-example.png)Figure 1. An Android app with three external IdP options: Google, Apple, and Facebook.
