Social Authentication

Authorize and authenticate your users using a Social Connection

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

Prerequisites

Android and iOS platforms each have their own configuration steps required to provide a secure Social authentication experience for your users. No additional configuration is needed for a web app.

Authorize Social Connection

iOS

To register or log in a user using a Social Connection on iOS, simply call passage.authorizeIOSWith(). Here is an example using Sign in with GitHub:

await passage.authorizeIOSWith(SocialConnection.github);
// If successful, you will be able to get the current user:
final user = await passage.getCurrentUser();

Android and Web

To register or log in a user using a Social Connection on Android and/or the web is a two part process. You'll first need to call passage.authorizeWith() to send the user to authenticate with the Social Connection provider.

await passage.authorizeWith(SocialConnection.github);

Upon successful authentication and authorization, the user will be redirected into your app. At that point, you'll grab the authorization code from the redirect url (likely using Flutter's Go Router (opens in a new tab) or an equivalent) and use that authorization code to finish authenticating your user. Here is an example using Sign in with GitHub:

String exampleRedirectUrl = "https://example.com/.../?code=SOME_AUTH_CODE";
String code = Uri.parse(exampleRedirectUrl).queryParameters['code'];
await passage.finishSocialAuthentication(code);
// If successful, you will be able to get the current user:
final user = await passage.getCurrentUser();