Skip to content

@capgo/capacitor-social-login

All social logins in one plugin.

@capgo/capacitor-social-login is the all-in-one social authentication plugin for Web, iOS, and Android.

It implements:

  • Google Sign-In with Android Credential Manager
  • Sign in with Apple, including OAuth on Android
  • Facebook Login with the current Facebook SDK
  • Twitter/X through OAuth 2.0
  • Generic OAuth2 and OIDC providers, including GitHub, Microsoft Entra ID, Auth0, Okta, Keycloak, and other compliant servers

It is also the Capgo migration path for apps moving from Ionic Appflow Social Login or Ionic Auth Connect.

This plugin started as a fork of @codetrix-studio/capacitor-google-auth. The original package is effectively archived, so Capgo maintains this plugin as the supported replacement.

If you are still using @codetrix-studio/capacitor-google-auth, follow the legacy Google Auth migration guide.

If you are migrating from Ionic Auth Connect, use the built-in SocialLoginAuthConnect wrapper for the auth0, azure, cognito, okta, and onelogin provider names:

Plugin versionCapacitor compatibilityMaintained
v8.xv8.xYes
v7.xv7.xOn demand
v6.xv6.xNo
v5.xv5.xNo

The major version of this plugin follows the major version of Capacitor. For example, use plugin v8 with Capacitor 8. Only the latest major version is actively maintained.

Watch a quick demo of the plugin setup and login flow in action.

  • initialize - Initialize the plugin.
  • login - Login with the selected provider.
  • logout - Logout.
  • isLoggedIn - IsLoggedIn.
MethodDescription
initializeInitialize the plugin.
loginLogin with the selected provider.
logoutLogout.
isLoggedInIsLoggedIn.
getAuthorizationCodeGet the current authorization code.
refreshRefresh the access token.
refreshTokenOAuth2 refresh-token helper for the built-in OAuth2 provider.
handleRedirectCallbackWeb-only: handle the OAuth redirect callback and return the parsed result.
decodeIdTokenDecode a JWT (typically an OIDC ID token) into its claims.
getAccessTokenExpirationDateConvert an access token expiration timestamp (milliseconds since epoch) to an ISO date string.
isAccessTokenAvailableCheck if an access token is available (non-empty).
isAccessTokenExpiredCheck if an access token is expired.
isRefreshTokenAvailableCheck if a refresh token is available (non-empty).
providerSpecificCallExecute provider-specific calls.
getPluginVersionGet the native Capacitor plugin version.
openSecureWindowOpens a secured window for OAuth2 authentication. For web, you should have the code in the redirected page to use a broadcast channel to send the redirected url to the app Something like: html <html> <head></head> <body> <script> const searchParams = new URLSearchParams(location.search) if (searchParams.has("code")) { new BroadcastChannel("my-channel-name").postMessage(location.href); window.close(); } </script> </body> </html> For mobile, you should have a redirect uri that opens the app, something like: myapp://oauth_callback/ And make sure to register it in the app’s info.plist: xml <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>myapp</string> </array> </dict> </array> And in the AndroidManifest.xml file: xml <activity> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="oauth_callback" android:scheme="myapp" /> </intent-filter> </activity> .

This reference is synced from src/definitions.ts in capacitor-social-login.

Keep going from @capgo/capacitor-social-login

Section titled “Keep going from @capgo/capacitor-social-login”

If you are using @capgo/capacitor-social-login to plan authentication and account flows, connect it with Using @capgo/capacitor-social-login for the native capability in Using @capgo/capacitor-social-login, @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, Two-factor authentication for the implementation detail in Two-factor authentication, and SSO (Enterprise) for the implementation detail in SSO (Enterprise).