Social Authentication

Authorize and authenticate a user using Social Connections

You can easily add Social Authentication to your app using providers like Google, Apple, or GitHub to authenticate your users. Before moving forward, you'll need to configure your Social Connection in the Passage Console.

Android Requirements

In order to securely use Social Authentication in your Android app, you'll need to set up your Android app for App Linking. This is a two step process:

If you have configured your Android app for passkeys, then you have already done this. If you have not, you can find out how to set up the asset links JSON file here.

2. Set up App Linking in your app

Setting up App Linking will allow the Social Connection provider to redirect your user back into your app after authorization to finish Passage authentication. Learn how to set up App Linking here.

Authorize Social Connection

To begin registering or logging in a user using a Social Connection, simply call passage.authorizeWith. Here is an example using Google Sign In:

passage.authorizeWith(PassageSocialConnection.google)

This will open up a secure web view where the user will be prompted to authorize the connection to your app via the provider.

Finish Authentication with Social Connection

When the user has successfully authorized the Social Connection in the web view, they will be redirected into your app where you will receive an authorization code. You will use this code to finish authentication.

// In your Activity
override fun onNewIntent(intent: Intent?) {
  val authCode = intent?.data?.getQueryParameter("code") ?: return
  scope.launch {
      try {
          passage.finishSocialAuthentication(authCode)
          // passage.getCurrentUser should now return the authenticated user
          val user = passage.getCurrentUser()
      } catch (e: FinishSocialAuthenticationException) {
          // Handle errors
      }
  }
}

Last updated