Passer au contenu

@capgo/capacitor-social-login

All social logins in one plugin.

All social logins in one plugin.

  • 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 (feature parity with Capawesome OAuth).
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.