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:

Publish a digital asset links JSON file

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.

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.social.authorize. Here is an example using Google Sign In:

passage.social.authorize(SocialConnection.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 aocial 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.social.finish(authCode)
          // passage.getCurrentUser should now return the authenticated user
          val user = passage.currentUser.userInfo()
          // Do authenticated stuff
      } catch (e: FinishSocialAuthenticationException) {
          // Handle errors
      }
  }
}