Microsoft Entra ID
Authentication

Tutorial Native Authentication Android Identity Provider Sign In Sign Up

In brief

The tutorial for adding federated identity provider sign-in and sign-up to Android apps through native authentication web flow has been deleted.

What Entra admins need to know

Administrators may no longer access this tutorial at its published documentation URL. No action is specified.

This editorial summary was generated by AI from the documentation changes. Verify important details in the full Microsoft Learn article.

Documentation change

The comparison below shows only the changed extract. Use the full-page view for complete context.

deleted file mode 100644

title: Add federated identity provider sign-in and sign-up to an Android app using native authentication web flow description: Learn how to enable federated identity provider sign-in and sign-up in an Android app using Microsoft Entra native authentication with web-based authentication flow.

manager: pmwongera

ms.service: identity-platform

ms.subservice: external ms.topic: tutorial ms.date: 04/10/2026 ai-usage: ai-assisted ms.custom: #Customer intent: As an Android developer, I want to enable federated identity provider sign-in and sign-up using native authentication web flow so that users can authenticate with existing social accounts like Apple, Google, or Facebook.

Tutorial: Add federated identity provider sign-in and sign-up web flow to your Android app

[!INCLUDE applies-to-external-only]

This tutorial demonstrates how to implement federated identity provider (IdP) authentication into your Android app using native authentication with web flow. Federated IdP authentication allows users to sign in or sign up using their existing accounts from providers like Apple, Facebook, Google and custom OIDC providers.

In this tutorial, you learn how to:

[!div class="checklist"]

  • Sign in a user using a federated identity provider via web flow
  • Sign up a user using a federated identity provider via web flow

Prerequisites

  1. Complete the steps in Tutorial: Prepare your Android mobile app for native authentication.

  2. Configure federated identity providers in your Microsoft Entra External ID tenant. Follow the steps in the Microsoft Entra admin center to add and configure your desired identity providers:

  3. If you'd like to explore our federated IdP Sign in and Sign up implementation, take a look at our sample Android application before getting started.

Sign in a user with a federated identity provider

To sign in a user with a federated identity provider via web flow, you need to first identify the identity provider to register/authenticate with, and the corresponding domain_hint.

  • Use the identity providers defined in the prerequisite configuration section.
  • Use the domain_hint parameter to direct authentication to a specific identity provider. Choose one of the following values:
    • "Apple" for Apple
    • "Facebook" for Facebook
    • "Google" for Google

To sign in a user, you need to:

  1. Create a user interface to sign in with a federated identity provider. This should identify a specific identity provider and its corresponding domain_hint.

  2. Once domain_hint value is identified from the client app, call INativeAuthPublicClientApplication.acquireToken with domain_hint to trigger web authentication with Social IdP. Here's a code snippet example:

    Use the Prompt value as Prompt.LOGIN to force interactive authentication, even if user is signed in.

    private fun signInWithIdp(domainHint: String) {
        val acquireTokenParameters = AcquireTokenParameters.Builder()
            .startAuthorizationFromActivity(requireActivity())
            .withScopes(listOf("openid", "profile", "email"))
            .withDomainHint(domainHint)
            .withPrompt(Prompt.LOGIN)
            .withCallback(getAuthenticationCallback())
            .build()
    
        authClient.acquireToken(acquireTokenParameters)
    }
    
  3. To handle the sign in results, you need to implement the AuthenticationCallback, example below:

    private fun getAuthenticationCallback(): AuthenticationCallback {
        return object : AuthenticationCallback {
    
            override fun onSuccess(authenticationResult: IAuthenticationResult) {
                Log.d(TAG, "Successfully authenticated with IdP")
    
                val account = authenticationResult.account
                val idToken = account.idToken
                val accessToken = authenticationResult.accessToken
    
                Toast.makeText(
                    requireContext(),
                    "Sign in successful!",
                    Toast.LENGTH_SHORT
                ).show()
            }
    
            override fun onError(exception: MsalException) {
                Log.e(TAG, "Authentication failed: ${exception.message}", exception)
    
                showErrorDialog(
                    "Sign in failed",
                    exception.message ?: "An error occurred during authentication"
                )
            }
    
            override fun onCancel() {
                Log.d(TAG, "User cancelled authentication")
    
                Toast.makeText(
                    requireContext(),
                    "Sign in cancelled",
                    Toast.LENGTH_SHORT
                ).show()
            }
        }
    }
    

    For error code and handling, refer to Handle errors and exceptions in MSAL for Android.

  4. You can also retrieve the current cached account after successful authentication by using the getCurrentAccount() from INativeAuthPublicClientApplication, which returns an object, accountResult:

    val accountResult = iNativeAuthPublicClientApplication.getCurrentAccount()
    
    when (accountResult) {
        is GetAccountResult.AccountFound -> {
            accountResult.resultValue.getIdToken()
        }
    
        is GetAccountResult.NoAccountFound -> {
            Log.d(TAG, "No account found")
        }
    
        is GetAccountError -> {
            displayDialog(
                getString(R.string.msal_exception_title),
                accountResult.exception?.message ?: accountResult.errorMessage
            )
        }
    }
    

Update configurations

  1. Ensure your client JSON configuration file includes the redirect_uri parameter for handling web-based authentication flows:

    {
        "client_id": "Enter_the_Application_Id_Here",
        "redirect_uri": "msauth://com.yourpackage.name/Enter_your_Signature_Hash_Here",
        "authorities": [
        {
            "type": "CIAM",
            "authority_url": "https://Enter_the_Tenant_Subdomain_Here.ciamlogin.com/Enter_the_Tenant_Subdomain_Here.onmicrosoft.com/"
        }
        ],
        ...
    }
    
  2. Add or update the MSAL dependency to at least 8.1.0 in your app's build.gradle file if not already present:

    dependencies {
        implementation 'com.microsoft.identity.client:msal:[8.1.0,)'
    }
    

Sign up a user with a federated identity provider

To sign up a user with a federated identity provider, the process is almost the same as signing in, with a minor change to the Prompt value: use Prompt.CREATE.

private fun signUpWithIdp(domainHint: String) {
    val acquireTokenParameters = AcquireTokenParameters.Builder()
        .startAuthorizationFromActivity(requireActivity())
        .withScopes(listOf("openid", "profile", "email"))
        .withDomainHint(domainHint)
        .withPrompt(Prompt.CREATE)
        .withCallback(getAuthenticationCallback())
        .build()

    authClient.acquireToken(acquireTokenParameters)
}

Related content

Daily Entra.News

Get daily email updates

Get a concise summary of the latest Microsoft Entra updates delivered straight to your inbox.

Loading the secure signup form…