@capgo/capacitor-social-login 8.5.4 → 8.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,6 +21,7 @@ This plugin implements social auth for:
21
21
  - Twitter/X (OAuth 2.0)
22
22
  - Telegram (Login Widget)
23
23
  - LinkedIn (OAuth 2.0 / OpenID Connect)
24
+ - TikTok (Login Kit / OAuth2)
24
25
  - Generic OAuth2 (supports multiple providers: GitHub, Azure AD, Auth0, Okta, and any OAuth2-compliant server)
25
26
 
26
27
  This plugin is the all-in-one solution for social authentication on Web, iOS, and Android.
@@ -615,6 +616,34 @@ console.log(res.result.resourceData); // LinkedIn userinfo payload
615
616
 
616
617
  You can still configure LinkedIn yourself via `oauth2.linkedin` if you need custom endpoints.
617
618
 
619
+ ## TikTok
620
+
621
+ TikTok Login Kit is a convenience wrapper around the generic OAuth2 engine. The plugin sends `client_key` (not `client_id`) and uses TikTok's v2 authorize/token endpoints. Login exchanges the authorization code in the plugin and does not return that code for backend exchange.
622
+
623
+ Create a TikTok developer app, enable Login Kit, and register your redirect URL, then:
624
+
625
+ ```typescript
626
+ await SocialLogin.initialize({
627
+ tiktok: {
628
+ clientKey: 'your-tiktok-client-key',
629
+ redirectUrl: 'https://your-app.example/auth/tiktok',
630
+ // Optional confidential-client secret; prefer PKCE for public apps
631
+ // clientSecret: 'your-tiktok-client-secret',
632
+ },
633
+ });
634
+
635
+ const res = await SocialLogin.login({
636
+ provider: 'tiktok',
637
+ options: {
638
+ // defaults to 'user.info.basic'
639
+ },
640
+ });
641
+
642
+ console.log(res.result.accessToken?.token);
643
+ ```
644
+
645
+ You can still configure TikTok yourself via `oauth2` plus `clientIdParamName: 'client_key'`.
646
+
618
647
  ## OAuth2 (Generic)
619
648
 
620
649
  The plugin supports generic OAuth2 authentication, allowing you to integrate with any OAuth2-compliant provider (GitHub, Azure AD, Auth0, Okta, Keycloak, custom servers, etc.). You can configure multiple OAuth2 providers simultaneously.
@@ -935,14 +964,14 @@ Initialize the plugin
935
964
  ### login(...)
936
965
 
937
966
  ```typescript
938
- login<T extends "apple" | "google" | "facebook" | "twitter" | "linkedin" | "oauth2" | "telegram">(options: Extract<LoginOptions, { provider: T; }>) => Promise<{ provider: T; result: ProviderResponseMap[T]; }>
967
+ login<T extends "apple" | "google" | "facebook" | "twitter" | "linkedin" | "tiktok" | "oauth2" | "telegram">(options: Extract<LoginOptions, { provider: T; }>) => Promise<{ provider: T; result: ProviderResponseMap[T]; }>
939
968
  ```
940
969
 
941
970
  Login with the selected provider
942
971
 
943
- | Param | Type |
944
- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
945
- | **`options`** | <code><a href="#extract">Extract</a>&lt;{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'telegram'; options: <a href="#telegramloginoptions">TelegramLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'linkedin'; options: <a href="#linkedinloginoptions">LinkedInLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }, { provider: T; }&gt;</code> |
972
+ | Param | Type |
973
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
974
+ | **`options`** | <code><a href="#extract">Extract</a>&lt;{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'telegram'; options: <a href="#telegramloginoptions">TelegramLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'linkedin'; options: <a href="#linkedinloginoptions">LinkedInLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'tiktok'; options: <a href="#tiktokloginoptions">TikTokLoginOptions</a>; }, { provider: T; }&gt; \| <a href="#extract">Extract</a>&lt;{ provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }, { provider: T; }&gt;</code> |
946
975
 
947
976
  **Returns:** <code>Promise&lt;{ provider: T; result: ProviderResponseMap[T]; }&gt;</code>
948
977
 
@@ -952,14 +981,14 @@ Login with the selected provider
952
981
  ### logout(...)
953
982
 
954
983
  ```typescript
955
- logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'oauth2'; providerId?: string; }) => Promise<void>
984
+ logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2'; providerId?: string; }) => Promise<void>
956
985
  ```
957
986
 
958
987
  Logout
959
988
 
960
- | Param | Type |
961
- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
962
- | **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'oauth2' \| 'telegram'; providerId?: string; }</code> |
989
+ | Param | Type |
990
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
991
+ | **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'tiktok' \| 'oauth2' \| 'telegram'; providerId?: string; }</code> |
963
992
 
964
993
  --------------------
965
994
 
@@ -1022,7 +1051,7 @@ refreshToken(options: RefreshTokenOptions) => Promise<OAuth2LoginResponse>
1022
1051
  OAuth2 refresh-token helper (feature parity with Capawesome OAuth).
1023
1052
 
1024
1053
  Scope:
1025
- - Applies to the built-in `oauth2` provider and the LinkedIn convenience wrapper.
1054
+ - Applies to the built-in `oauth2` provider and the LinkedIn and TikTok convenience wrappers.
1026
1055
  - Requires a token endpoint (either `accessTokenEndpoint`/`tokenEndpoint` or `issuerUrl` discovery).
1027
1056
 
1028
1057
  Security note:
@@ -1262,6 +1291,7 @@ And in the AndroidManifest.xml file:
1262
1291
  | **`oauth2`** | <code><a href="#record">Record</a>&lt;string, <a href="#oauth2providerconfig">OAuth2ProviderConfig</a>&gt;</code> | OAuth2 provider configurations. Supports multiple providers by using a <a href="#record">Record</a> with provider IDs as keys. |
1263
1292
  | **`telegram`** | <code>{ botId: string; redirectUrl?: string; origin?: string; requestAccess?: 'read' \| 'write'; languageCode?: string; }</code> | Telegram Login Widget configuration. Uses Telegram's OAuth widget (`oauth.telegram.org`), not standard OAuth2. |
1264
1293
  | **`linkedin`** | <code><a href="#linkedinproviderconfig">LinkedInProviderConfig</a></code> | LinkedIn configuration. Convenience wrapper that maps to the OAuth2 provider using LinkedIn defaults. |
1294
+ | **`tiktok`** | <code><a href="#tiktokproviderconfig">TikTokProviderConfig</a></code> | TikTok Login Kit configuration. Convenience wrapper that maps to the OAuth2 provider using TikTok defaults (`client_key`). |
1265
1295
  | **`twitter`** | <code>{ clientId: string; redirectUrl: string; defaultScopes?: string[]; forceLogin?: boolean; audience?: string; }</code> | |
1266
1296
  | **`facebook`** | <code>{ appId: string; clientToken?: string; locale?: string; }</code> | |
1267
1297
  | **`google`** | <code>{ iOSClientId?: string; iOSServerClientId?: string; webClientId?: string; mode?: 'online' \| 'offline'; hostedDomain?: string; redirectUrl?: string; }</code> | |
@@ -1272,35 +1302,37 @@ And in the AndroidManifest.xml file:
1272
1302
 
1273
1303
  Configuration for a single OAuth2 provider instance
1274
1304
 
1275
- | Prop | Type | Description | Default |
1276
- | ------------------------------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
1277
- | **`appId`** | <code>string</code> | The OAuth 2.0 client identifier (App ID / Client ID). Note: this configuration object is only used by the plugin's built-in `oauth2` provider (i.e. `SocialLogin.initialize({ oauth2: { ... } })`). It does not affect Google/Apple/Facebook/Twitter. | |
1278
- | **`clientId`** | <code>string</code> | Alias for `appId` to match common OAuth/OIDC naming (`clientId`). If both are provided, `appId` takes precedence. | |
1279
- | **`issuerUrl`** | <code>string</code> | OpenID Connect issuer URL (enables discovery via `/.well-known/openid-configuration`). When set, you may omit explicit endpoints like `authorizationBaseUrl` and `accessTokenEndpoint`. Notes: - Explicit endpoints (authorization/token/logout) take precedence over discovered values. - Discovery is supported for `oauth2` on Web, iOS, and Android. | |
1280
- | **`authorizationBaseUrl`** | <code>string</code> | The base URL of the authorization endpoint | |
1281
- | **`authorizationEndpoint`** | <code>string</code> | Alias for `authorizationBaseUrl` (to match common OAuth/OIDC naming). | |
1282
- | **`clientSecret`** | <code>string</code> | OAuth 2.0 client secret for token requests (e.g., when exchanging the code). This value is sent as `client_secret` in token/refresh requests when provided. | |
1283
- | **`accessTokenEndpoint`** | <code>string</code> | The URL to exchange the authorization code for tokens Required for authorization code flow | |
1284
- | **`tokenEndpoint`** | <code>string</code> | Alias for `accessTokenEndpoint` (to match common OAuth/OIDC naming). | |
1285
- | **`redirectUrl`** | <code>string</code> | Redirect URL that receives the OAuth callback | |
1286
- | **`resourceUrl`** | <code>string</code> | Optional URL to fetch user profile/resource data after authentication The access token will be sent as Bearer token in the Authorization header | |
1287
- | **`responseType`** | <code>'code' \| 'token'</code> | The OAuth response type - 'code': Authorization Code flow (recommended, requires accessTokenEndpoint) - 'token': Implicit flow (less secure, tokens returned directly) | <code>'code'</code> |
1288
- | **`pkceEnabled`** | <code>boolean</code> | Enable PKCE (Proof Key for Code Exchange) Strongly recommended for public clients (mobile/web apps) | <code>true</code> |
1289
- | **`scope`** | <code>string \| string[]</code> | Default scopes to request during authorization | |
1290
- | **`scopes`** | <code>string[]</code> | Alias for `scope` using common naming (`scopes`). If both are provided, `scope` takes precedence. | |
1291
- | **`additionalParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in the authorization request | |
1292
- | **`loginHint`** | <code>string</code> | Convenience option for OIDC `login_hint`. Equivalent to passing `additionalParameters.login_hint`. | |
1293
- | **`prompt`** | <code>string</code> | Convenience option for OAuth/OIDC `prompt`. Equivalent to passing `additionalParameters.prompt`. | |
1294
- | **`additionalTokenParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in token requests (code exchange / refresh). Useful for providers that require non-standard parameters. | |
1295
- | **`additionalResourceHeaders`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional headers to include when fetching the resource URL | |
1296
- | **`logoutUrl`** | <code>string</code> | Custom logout URL for ending the session | |
1297
- | **`endSessionEndpoint`** | <code>string</code> | Alias for `logoutUrl` to match OIDC naming (`endSessionEndpoint`). | |
1298
- | **`postLogoutRedirectUrl`** | <code>string</code> | OIDC post logout redirect URL (sent as `post_logout_redirect_uri` when building the end-session URL). | |
1299
- | **`additionalLogoutParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in logout / end-session URL. | |
1300
- | **`iosPrefersEphemeralWebBrowserSession`** | <code>boolean</code> | iOS-only: Whether to prefer an ephemeral browser session for ASWebAuthenticationSession. Defaults to true to match existing behavior in this plugin. | |
1301
- | **`iosPrefersEphemeralSession`** | <code>boolean</code> | Alias for `iosPrefersEphemeralWebBrowserSession` (to match Capawesome OAuth naming). | |
1302
- | **`androidUseCustomTabs`** | <code>boolean</code> | Android-only: Use Chrome Custom Tabs (system browser) instead of an embedded WebView for the authorization request. Custom Tabs follow RFC 8252 (OAuth 2.0 for Native Apps) and fix issues with brokered IdPs (Microsoft Entra Conditional Access / Authenticator, passkeys/WebAuthn, Google `disallowed_useragent`, SSO cookie sharing, password managers). Requires a custom-scheme or App Link `redirectUrl` with a matching intent filter in your app's `AndroidManifest.xml` (same setup as `openSecureWindow()` / Apple on Android). Defaults to `false` to preserve the historical WebView flow. | <code>false</code> |
1303
- | **`logsEnabled`** | <code>boolean</code> | Enable debug logging | <code>false</code> |
1305
+ | Prop | Type | Description | Default |
1306
+ | ------------------------------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
1307
+ | **`appId`** | <code>string</code> | The OAuth 2.0 client identifier (App ID / Client ID). Note: this configuration object is only used by the plugin's built-in `oauth2` provider (i.e. `SocialLogin.initialize({ oauth2: { ... } })`). It does not affect Google/Apple/Facebook/Twitter. | |
1308
+ | **`clientId`** | <code>string</code> | Alias for `appId` to match common OAuth/OIDC naming (`clientId`). If both are provided, `appId` takes precedence. | |
1309
+ | **`issuerUrl`** | <code>string</code> | OpenID Connect issuer URL (enables discovery via `/.well-known/openid-configuration`). When set, you may omit explicit endpoints like `authorizationBaseUrl` and `accessTokenEndpoint`. Notes: - Explicit endpoints (authorization/token/logout) take precedence over discovered values. - Discovery is supported for `oauth2` on Web, iOS, and Android. | |
1310
+ | **`authorizationBaseUrl`** | <code>string</code> | The base URL of the authorization endpoint | |
1311
+ | **`authorizationEndpoint`** | <code>string</code> | Alias for `authorizationBaseUrl` (to match common OAuth/OIDC naming). | |
1312
+ | **`clientSecret`** | <code>string</code> | OAuth 2.0 client secret for token requests (e.g., when exchanging the code). When provided, this value is sent using `clientSecretParamName` (default `client_secret`). | |
1313
+ | **`clientIdParamName`** | <code>string</code> | Override the client identifier parameter name used for authorization and token requests. Some providers (e.g. TikTok) expect `client_key` instead of the default `client_id`. | <code>'client_id'</code> |
1314
+ | **`clientSecretParamName`** | <code>string</code> | Override the client secret parameter name used for token requests. Useful for providers that expect a different parameter name. | <code>'client_secret'</code> |
1315
+ | **`accessTokenEndpoint`** | <code>string</code> | The URL to exchange the authorization code for tokens Required for authorization code flow | |
1316
+ | **`tokenEndpoint`** | <code>string</code> | Alias for `accessTokenEndpoint` (to match common OAuth/OIDC naming). | |
1317
+ | **`redirectUrl`** | <code>string</code> | Redirect URL that receives the OAuth callback | |
1318
+ | **`resourceUrl`** | <code>string</code> | Optional URL to fetch user profile/resource data after authentication The access token will be sent as Bearer token in the Authorization header | |
1319
+ | **`responseType`** | <code>'code' \| 'token'</code> | The OAuth response type - 'code': Authorization Code flow (recommended, requires accessTokenEndpoint) - 'token': Implicit flow (less secure, tokens returned directly) | <code>'code'</code> |
1320
+ | **`pkceEnabled`** | <code>boolean</code> | Enable PKCE (Proof Key for Code Exchange) Strongly recommended for public clients (mobile/web apps) | <code>true</code> |
1321
+ | **`scope`** | <code>string \| string[]</code> | Default scopes to request during authorization | |
1322
+ | **`scopes`** | <code>string[]</code> | Alias for `scope` using common naming (`scopes`). If both are provided, `scope` takes precedence. | |
1323
+ | **`additionalParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in the authorization request | |
1324
+ | **`loginHint`** | <code>string</code> | Convenience option for OIDC `login_hint`. Equivalent to passing `additionalParameters.login_hint`. | |
1325
+ | **`prompt`** | <code>string</code> | Convenience option for OAuth/OIDC `prompt`. Equivalent to passing `additionalParameters.prompt`. | |
1326
+ | **`additionalTokenParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in token requests (code exchange / refresh). Useful for providers that require non-standard parameters. | |
1327
+ | **`additionalResourceHeaders`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional headers to include when fetching the resource URL | |
1328
+ | **`logoutUrl`** | <code>string</code> | Custom logout URL for ending the session | |
1329
+ | **`endSessionEndpoint`** | <code>string</code> | Alias for `logoutUrl` to match OIDC naming (`endSessionEndpoint`). | |
1330
+ | **`postLogoutRedirectUrl`** | <code>string</code> | OIDC post logout redirect URL (sent as `post_logout_redirect_uri` when building the end-session URL). | |
1331
+ | **`additionalLogoutParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in logout / end-session URL. | |
1332
+ | **`iosPrefersEphemeralWebBrowserSession`** | <code>boolean</code> | iOS-only: Whether to prefer an ephemeral browser session for ASWebAuthenticationSession. Defaults to true to match existing behavior in this plugin. | |
1333
+ | **`iosPrefersEphemeralSession`** | <code>boolean</code> | Alias for `iosPrefersEphemeralWebBrowserSession` (to match Capawesome OAuth naming). | |
1334
+ | **`androidUseCustomTabs`** | <code>boolean</code> | Android-only: Use Chrome Custom Tabs (system browser) instead of an embedded WebView for the authorization request. Custom Tabs follow RFC 8252 (OAuth 2.0 for Native Apps) and fix issues with brokered IdPs (Microsoft Entra Conditional Access / Authenticator, passkeys/WebAuthn, Google `disallowed_useragent`, SSO cookie sharing, password managers). Requires a custom-scheme or App Link `redirectUrl` with a matching intent filter in your app's `AndroidManifest.xml` (same setup as `openSecureWindow()` / Apple on Android). Defaults to `false` to preserve the historical WebView flow. | <code>false</code> |
1335
+ | **`logsEnabled`** | <code>boolean</code> | Enable debug logging | <code>false</code> |
1304
1336
 
1305
1337
 
1306
1338
  #### LinkedInProviderConfig
@@ -1320,6 +1352,23 @@ Uses the OAuth2 engine with LinkedIn defaults:
1320
1352
  | **`clientSecret`** | <code>string</code> | LinkedIn Client Secret. Prefer exchanging the authorization code on a backend when possible. Needed for confidential clients that do not use PKCE-only token exchange. |
1321
1353
 
1322
1354
 
1355
+ #### TikTokProviderConfig
1356
+
1357
+ TikTok Login Kit configuration (convenience wrapper around the generic OAuth2 provider).
1358
+
1359
+ Uses TikTok OAuth 2.0 endpoints and `client_key` instead of `client_id`.
1360
+
1361
+ | Prop | Type | Description | Default |
1362
+ | ------------------ | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
1363
+ | **`clientKey`** | <code>string</code> | TikTok client key (also known as app key). | |
1364
+ | **`redirectUrl`** | <code>string</code> | Redirect URL registered in your TikTok developer app. | |
1365
+ | **`clientSecret`** | <code>string</code> | TikTok client secret. Optional. When set, the plugin includes it on token and refresh requests. On web this value is stored with the OAuth2 config. Login always exchanges the authorization code in the plugin; the raw code is not returned to the app. | |
1366
+ | **`scopes`** | <code>string[]</code> | Scopes to request during login. Arrays are sent as a comma-separated string (TikTok Login Kit). | <code>['user.info.basic']</code> |
1367
+ | **`scope`** | <code>string \| string[]</code> | Alias for `scopes`. | |
1368
+ | **`pkceEnabled`** | <code>boolean</code> | Toggle PKCE usage during the authorization code flow. | <code>true</code> |
1369
+ | **`logsEnabled`** | <code>boolean</code> | Enable verbose debug logging for the TikTok OAuth2 flow. | <code>false</code> |
1370
+
1371
+
1323
1372
  #### FacebookLoginResponse
1324
1373
 
1325
1374
  | Prop | Type | Description | Since |
@@ -1502,12 +1551,23 @@ Uses the OAuth2 engine with LinkedIn defaults:
1502
1551
  | **`flow`** | <code>'popup' \| 'redirect'</code> | Web-only (`oauth2` provider only): Use a full-page redirect instead of a popup window. When using `redirect`, the promise returned by `login()` will not resolve because the page navigates away. After the redirect lands back in your app, call `SocialLogin.handleRedirectCallback()` on that page to parse the result. | <code>'popup'</code> |
1503
1552
 
1504
1553
 
1554
+ #### TikTokLoginOptions
1555
+
1556
+ | Prop | Type | Description |
1557
+ | ------------------ | ------------------------------- | ------------------------------------------------------ |
1558
+ | **`scopes`** | <code>string[]</code> | Optional scopes to override the initialization scopes. |
1559
+ | **`scope`** | <code>string \| string[]</code> | Alias for `scopes`. |
1560
+ | **`state`** | <code>string</code> | Custom state parameter for CSRF protection. |
1561
+ | **`codeVerifier`** | <code>string</code> | Custom PKCE code verifier (mostly for testing). |
1562
+ | **`redirectUrl`** | <code>string</code> | Override redirect URL for this login request. |
1563
+
1564
+
1505
1565
  #### isLoggedInOptions
1506
1566
 
1507
- | Prop | Type | Description |
1508
- | ---------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
1509
- | **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'oauth2' \| 'telegram'</code> | Provider |
1510
- | **`providerId`** | <code>string</code> | Provider ID for OAuth2 providers (required when provider is 'oauth2') |
1567
+ | Prop | Type | Description |
1568
+ | ---------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
1569
+ | **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'tiktok' \| 'oauth2' \| 'telegram'</code> | Provider |
1570
+ | **`providerId`** | <code>string</code> | Provider ID for OAuth2 providers (required when provider is 'oauth2') |
1511
1571
 
1512
1572
 
1513
1573
  #### AuthorizationCode
@@ -1520,10 +1580,10 @@ Uses the OAuth2 engine with LinkedIn defaults:
1520
1580
 
1521
1581
  #### AuthorizationCodeOptions
1522
1582
 
1523
- | Prop | Type | Description |
1524
- | ---------------- | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
1525
- | **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'oauth2'</code> | Provider |
1526
- | **`providerId`** | <code>string</code> | Provider ID for OAuth2 providers (required when provider is 'oauth2') |
1583
+ | Prop | Type | Description |
1584
+ | ---------------- | ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
1585
+ | **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'tiktok' \| 'oauth2'</code> | Provider |
1586
+ | **`providerId`** | <code>string</code> | Provider ID for OAuth2 providers (required when provider is 'oauth2') |
1527
1587
 
1528
1588
 
1529
1589
  #### FacebookGetProfileResponse
@@ -1632,7 +1692,7 @@ Construct a type with a set of properties K of type T
1632
1692
 
1633
1693
  #### ProviderResponseMap
1634
1694
 
1635
- <code>{ facebook: <a href="#facebookloginresponse">FacebookLoginResponse</a>; google: <a href="#googleloginresponse">GoogleLoginResponse</a>; apple: <a href="#appleproviderresponse">AppleProviderResponse</a>; twitter: <a href="#twitterloginresponse">TwitterLoginResponse</a>; telegram: <a href="#telegramloginresponse">TelegramLoginResponse</a>; linkedin: <a href="#linkedinloginresponse">LinkedInLoginResponse</a>; oauth2: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
1695
+ <code>{ facebook: <a href="#facebookloginresponse">FacebookLoginResponse</a>; google: <a href="#googleloginresponse">GoogleLoginResponse</a>; apple: <a href="#appleproviderresponse">AppleProviderResponse</a>; twitter: <a href="#twitterloginresponse">TwitterLoginResponse</a>; telegram: <a href="#telegramloginresponse">TelegramLoginResponse</a>; linkedin: <a href="#linkedinloginresponse">LinkedInLoginResponse</a>; tiktok: <a href="#tiktokloginresponse">TikTokLoginResponse</a>; oauth2: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
1636
1696
 
1637
1697
 
1638
1698
  #### GoogleLoginResponse
@@ -1647,9 +1707,16 @@ LinkedIn login response (returned when using the LinkedIn convenience API).
1647
1707
  <code><a href="#oauth2loginresponse">OAuth2LoginResponse</a></code>
1648
1708
 
1649
1709
 
1710
+ #### TikTokLoginResponse
1711
+
1712
+ TikTok login response (same shape as generic OAuth2).
1713
+
1714
+ <code><a href="#oauth2loginresponse">OAuth2LoginResponse</a></code>
1715
+
1716
+
1650
1717
  #### LoginOptions
1651
1718
 
1652
- <code>{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; } | { provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; } | { provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; } | { provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; } | { provider: 'telegram'; options: <a href="#telegramloginoptions">TelegramLoginOptions</a>; } | { provider: 'linkedin'; options: <a href="#linkedinloginoptions">LinkedInLoginOptions</a>; } | { provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }</code>
1719
+ <code>{ provider: 'facebook'; options: <a href="#facebookloginoptions">FacebookLoginOptions</a>; } | { provider: 'google'; options: <a href="#googleloginoptions">GoogleLoginOptions</a>; } | { provider: 'apple'; options: <a href="#appleprovideroptions">AppleProviderOptions</a>; } | { provider: 'twitter'; options: <a href="#twitterloginoptions">TwitterLoginOptions</a>; } | { provider: 'telegram'; options: <a href="#telegramloginoptions">TelegramLoginOptions</a>; } | { provider: 'linkedin'; options: <a href="#linkedinloginoptions">LinkedInLoginOptions</a>; } | { provider: 'tiktok'; options: <a href="#tiktokloginoptions">TikTokLoginOptions</a>; } | { provider: 'oauth2'; options: <a href="#oauth2loginoptions">OAuth2LoginOptions</a>; }</code>
1653
1720
 
1654
1721
 
1655
1722
  #### LinkedInLoginOptions
@@ -1691,14 +1758,14 @@ From T, pick a set of properties whose keys are in the union K
1691
1758
  #### RefreshTokenOptions
1692
1759
 
1693
1760
  Options for `refreshToken()`.
1694
- `providerId` is required for generic `oauth2` and ignored for LinkedIn.
1761
+ `providerId` is required for generic `oauth2` and ignored for LinkedIn and TikTok.
1695
1762
 
1696
- <code>{ provider: 'oauth2'; providerId: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a>&lt;string, string&gt;; } | { provider: 'linkedin'; providerId?: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a>&lt;string, string&gt;; }</code>
1763
+ <code>{ provider: 'oauth2'; providerId: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a>&lt;string, string&gt;; } | { provider: 'linkedin'; providerId?: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a>&lt;string, string&gt;; } | { provider: 'tiktok'; providerId?: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a>&lt;string, string&gt;; }</code>
1697
1764
 
1698
1765
 
1699
1766
  #### LoginResult
1700
1767
 
1701
- <code>{ provider: 'facebook'; result: <a href="#facebookloginresponse">FacebookLoginResponse</a>; } | { provider: 'google'; result: <a href="#googleloginresponse">GoogleLoginResponse</a>; } | { provider: 'apple'; result: <a href="#appleproviderresponse">AppleProviderResponse</a>; } | { provider: 'twitter'; result: <a href="#twitterloginresponse">TwitterLoginResponse</a>; } | { provider: 'telegram'; result: <a href="#telegramloginresponse">TelegramLoginResponse</a>; } | { provider: 'linkedin'; result: <a href="#linkedinloginresponse">LinkedInLoginResponse</a>; } | { provider: 'oauth2'; result: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
1768
+ <code>{ provider: 'facebook'; result: <a href="#facebookloginresponse">FacebookLoginResponse</a>; } | { provider: 'google'; result: <a href="#googleloginresponse">GoogleLoginResponse</a>; } | { provider: 'apple'; result: <a href="#appleproviderresponse">AppleProviderResponse</a>; } | { provider: 'twitter'; result: <a href="#twitterloginresponse">TwitterLoginResponse</a>; } | { provider: 'telegram'; result: <a href="#telegramloginresponse">TelegramLoginResponse</a>; } | { provider: 'linkedin'; result: <a href="#linkedinloginresponse">LinkedInLoginResponse</a>; } | { provider: 'tiktok'; result: <a href="#tiktokloginresponse">TikTokLoginResponse</a>; } | { provider: 'oauth2'; result: <a href="#oauth2loginresponse">OAuth2LoginResponse</a>; }</code>
1702
1769
 
1703
1770
 
1704
1771
  #### ProviderSpecificCallResponseMap
@@ -100,6 +100,8 @@ public class OAuth2Provider implements SocialProvider {
100
100
  final Map<String, String> additionalLogoutParameters;
101
101
  final boolean androidUseCustomTabs;
102
102
  final boolean logsEnabled;
103
+ final String clientIdParamName;
104
+ final String clientSecretParamName;
103
105
 
104
106
  OAuth2ProviderConfig(
105
107
  String appId,
@@ -121,7 +123,9 @@ public class OAuth2Provider implements SocialProvider {
121
123
  String postLogoutRedirectUrl,
122
124
  Map<String, String> additionalLogoutParameters,
123
125
  boolean androidUseCustomTabs,
124
- boolean logsEnabled
126
+ boolean logsEnabled,
127
+ String clientIdParamName,
128
+ String clientSecretParamName
125
129
  ) {
126
130
  this.appId = appId;
127
131
  this.clientSecret = clientSecret;
@@ -143,6 +147,10 @@ public class OAuth2Provider implements SocialProvider {
143
147
  this.additionalLogoutParameters = additionalLogoutParameters;
144
148
  this.androidUseCustomTabs = androidUseCustomTabs;
145
149
  this.logsEnabled = logsEnabled;
150
+ String trimmedClientIdParamName = clientIdParamName == null ? "" : clientIdParamName.trim();
151
+ String trimmedClientSecretParamName = clientSecretParamName == null ? "" : clientSecretParamName.trim();
152
+ this.clientIdParamName = trimmedClientIdParamName.isEmpty() ? "client_id" : trimmedClientIdParamName;
153
+ this.clientSecretParamName = trimmedClientSecretParamName.isEmpty() ? "client_secret" : trimmedClientSecretParamName;
146
154
  }
147
155
  }
148
156
 
@@ -253,7 +261,9 @@ public class OAuth2Provider implements SocialProvider {
253
261
  config.postLogoutRedirectUrl,
254
262
  config.additionalLogoutParameters,
255
263
  config.androidUseCustomTabs,
256
- config.logsEnabled
264
+ config.logsEnabled,
265
+ config.clientIdParamName,
266
+ config.clientSecretParamName
257
267
  );
258
268
  providers.put(providerId, resolved);
259
269
  cb.onSuccess(resolved);
@@ -347,7 +357,9 @@ public class OAuth2Provider implements SocialProvider {
347
357
  config.optString("postLogoutRedirectUrl", null),
348
358
  additionalLogoutParameters,
349
359
  config.optBoolean("androidUseCustomTabs", false),
350
- config.optBoolean("logsEnabled", false)
360
+ config.optBoolean("logsEnabled", false),
361
+ oauthParamName(config, "clientIdParamName", "client_id"),
362
+ oauthParamName(config, "clientSecretParamName", "client_secret")
351
363
  );
352
364
 
353
365
  providers.put(providerId, providerConfig);
@@ -452,7 +464,7 @@ public class OAuth2Provider implements SocialProvider {
452
464
  Uri.Builder builder = Uri.parse(resolved.authorizationBaseUrl)
453
465
  .buildUpon()
454
466
  .appendQueryParameter("response_type", resolved.responseType)
455
- .appendQueryParameter("client_id", resolved.appId)
467
+ .appendQueryParameter(resolved.clientIdParamName, resolved.appId)
456
468
  .appendQueryParameter("redirect_uri", finalRedirect)
457
469
  .appendQueryParameter("state", finalState);
458
470
 
@@ -1071,7 +1083,7 @@ public class OAuth2Provider implements SocialProvider {
1071
1083
 
1072
1084
  FormBody.Builder bodyBuilder = new FormBody.Builder()
1073
1085
  .add("grant_type", "authorization_code")
1074
- .add("client_id", config.appId)
1086
+ .add(config.clientIdParamName, config.appId)
1075
1087
  .add("code", code)
1076
1088
  .add("redirect_uri", pendingState.redirectUri);
1077
1089
 
@@ -1080,7 +1092,7 @@ public class OAuth2Provider implements SocialProvider {
1080
1092
  }
1081
1093
 
1082
1094
  if (config.clientSecret != null) {
1083
- bodyBuilder.add("client_secret", config.clientSecret);
1095
+ bodyBuilder.add(config.clientSecretParamName, config.clientSecret);
1084
1096
  }
1085
1097
 
1086
1098
  if (config.additionalTokenParameters != null) {
@@ -1167,10 +1179,10 @@ public class OAuth2Provider implements SocialProvider {
1167
1179
  FormBody.Builder bodyBuilder = new FormBody.Builder()
1168
1180
  .add("grant_type", "refresh_token")
1169
1181
  .add("refresh_token", refreshToken)
1170
- .add("client_id", config.appId);
1182
+ .add(config.clientIdParamName, config.appId);
1171
1183
 
1172
1184
  if (config.clientSecret != null) {
1173
- bodyBuilder.add("client_secret", config.clientSecret);
1185
+ bodyBuilder.add(config.clientSecretParamName, config.clientSecret);
1174
1186
  }
1175
1187
 
1176
1188
  if (config.additionalTokenParameters != null) {
@@ -1481,6 +1493,18 @@ public class OAuth2Provider implements SocialProvider {
1481
1493
  clearPersistedCustomTabsState();
1482
1494
  }
1483
1495
 
1496
+ private static String oauthParamName(JSONObject config, String key, String fallback) {
1497
+ if (config.isNull(key)) {
1498
+ return fallback;
1499
+ }
1500
+ String value = config.optString(key, fallback);
1501
+ if (value == null) {
1502
+ return fallback;
1503
+ }
1504
+ String trimmed = value.trim();
1505
+ return trimmed.isEmpty() ? fallback : trimmed;
1506
+ }
1507
+
1484
1508
  private static Map<String, String> jsonObjectToMap(JSONObject json) throws JSONException {
1485
1509
  Map<String, String> map = new HashMap<>();
1486
1510
  Iterator<String> keys = json.keys();
@@ -24,7 +24,7 @@ import org.json.JSONObject;
24
24
  @CapacitorPlugin(name = "SocialLogin")
25
25
  public class SocialLoginPlugin extends Plugin {
26
26
 
27
- private final String pluginVersion = "8.5.4";
27
+ private final String pluginVersion = "8.5.6";
28
28
 
29
29
  public static String LOG_TAG = "CapgoSocialLogin";
30
30
  public HashMap<String, SocialProvider> socialProviderHashMap = new HashMap<>();