@capgo/capacitor-social-login 8.5.3 → 8.5.5

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
@@ -20,6 +20,8 @@ This plugin implements social auth for:
20
20
  - Facebook (with latest SDK)
21
21
  - Twitter/X (OAuth 2.0)
22
22
  - Telegram (Login Widget)
23
+ - LinkedIn (OAuth 2.0 / OpenID Connect)
24
+ - TikTok (Login Kit / OAuth2)
23
25
  - Generic OAuth2 (supports multiple providers: GitHub, Azure AD, Auth0, Okta, and any OAuth2-compliant server)
24
26
 
25
27
  This plugin is the all-in-one solution for social authentication on Web, iOS, and Android.
@@ -585,6 +587,63 @@ const res = await SocialLogin.login({
585
587
  console.log(res.result.profile.id, res.result.hash);
586
588
  ```
587
589
 
590
+ ## LinkedIn
591
+
592
+ LinkedIn is a convenience wrapper around the generic OAuth2 engine (OpenID Connect `userinfo`).
593
+
594
+ Register a web app in the [LinkedIn Developer Portal](https://www.linkedin.com/developers/apps) with the **Sign In with LinkedIn using OpenID Connect** product, then:
595
+
596
+ ```typescript
597
+ await SocialLogin.initialize({
598
+ linkedin: {
599
+ clientId: 'your-linkedin-client-id',
600
+ redirectUrl: 'https://your-app.example/auth/linkedin',
601
+ // Optional: only if your LinkedIn app is a confidential client
602
+ // clientSecret: 'your-linkedin-client-secret',
603
+ },
604
+ });
605
+
606
+ const res = await SocialLogin.login({
607
+ provider: 'linkedin',
608
+ options: {
609
+ // defaults to 'openid profile email'
610
+ },
611
+ });
612
+
613
+ console.log(res.result.accessToken?.token);
614
+ console.log(res.result.resourceData); // LinkedIn userinfo payload
615
+ ```
616
+
617
+ You can still configure LinkedIn yourself via `oauth2.linkedin` if you need custom endpoints.
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
+
588
647
  ## OAuth2 (Generic)
589
648
 
590
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.
@@ -905,14 +964,14 @@ Initialize the plugin
905
964
  ### login(...)
906
965
 
907
966
  ```typescript
908
- login<T extends "apple" | "google" | "facebook" | "twitter" | "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]; }>
909
968
  ```
910
969
 
911
970
  Login with the selected provider
912
971
 
913
- | Param | Type |
914
- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
915
- | **`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: '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> |
916
975
 
917
976
  **Returns:** <code>Promise&lt;{ provider: T; result: ProviderResponseMap[T]; }&gt;</code>
918
977
 
@@ -922,14 +981,14 @@ Login with the selected provider
922
981
  ### logout(...)
923
982
 
924
983
  ```typescript
925
- logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'oauth2'; providerId?: string; }) => Promise<void>
984
+ logout(options: { provider: 'apple' | 'google' | 'facebook' | 'twitter' | 'telegram' | 'linkedin' | 'tiktok' | 'oauth2'; providerId?: string; }) => Promise<void>
926
985
  ```
927
986
 
928
987
  Logout
929
988
 
930
- | Param | Type |
931
- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
932
- | **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'oauth2' \| 'telegram'; providerId?: string; }</code> |
989
+ | Param | Type |
990
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
991
+ | **`options`** | <code>{ provider: 'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'linkedin' \| 'tiktok' \| 'oauth2' \| 'telegram'; providerId?: string; }</code> |
933
992
 
934
993
  --------------------
935
994
 
@@ -986,13 +1045,13 @@ Refresh the access token
986
1045
  ### refreshToken(...)
987
1046
 
988
1047
  ```typescript
989
- refreshToken(options: { provider: 'oauth2'; providerId: string; refreshToken?: string; additionalParameters?: Record<string, string>; }) => Promise<OAuth2LoginResponse>
1048
+ refreshToken(options: RefreshTokenOptions) => Promise<OAuth2LoginResponse>
990
1049
  ```
991
1050
 
992
1051
  OAuth2 refresh-token helper (feature parity with Capawesome OAuth).
993
1052
 
994
1053
  Scope:
995
- - Only applies to the built-in `oauth2` provider (not Google/Apple/Facebook/Twitter).
1054
+ - Applies to the built-in `oauth2` provider and the LinkedIn and TikTok convenience wrappers.
996
1055
  - Requires a token endpoint (either `accessTokenEndpoint`/`tokenEndpoint` or `issuerUrl` discovery).
997
1056
 
998
1057
  Security note:
@@ -1000,9 +1059,9 @@ Security note:
1000
1059
 
1001
1060
  If `refreshToken` is omitted, the plugin will attempt to use the stored refresh token (if available).
1002
1061
 
1003
- | Param | Type |
1004
- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
1005
- | **`options`** | <code>{ provider: 'oauth2'; providerId: string; refreshToken?: string; additionalParameters?: <a href="#record">Record</a>&lt;string, string&gt;; }</code> |
1062
+ | Param | Type |
1063
+ | ------------- | ------------------------------------------------------------------- |
1064
+ | **`options`** | <code><a href="#refreshtokenoptions">RefreshTokenOptions</a></code> |
1006
1065
 
1007
1066
  **Returns:** <code>Promise&lt;<a href="#oauth2loginresponse">OAuth2LoginResponse</a>&gt;</code>
1008
1067
 
@@ -1020,6 +1079,8 @@ Web-only: handle the OAuth redirect callback and return the parsed result.
1020
1079
  Notes:
1021
1080
  - This is only meaningful on Web. iOS/Android implementations will reject.
1022
1081
  - Intended for redirect-based flows (e.g. `oauth2` with `flow: 'redirect'`) where the page navigates away.
1082
+ - LinkedIn convenience logins (`provider: 'linkedin'`, `flow: 'redirect'`) return `provider: 'linkedin'`.
1083
+ The same app used as `oauth2` with `providerId: 'linkedin'` keeps `provider: 'oauth2'`.
1023
1084
 
1024
1085
  **Returns:** <code>Promise&lt;<a href="#loginresult">LoginResult</a> | null&gt;</code>
1025
1086
 
@@ -1229,6 +1290,8 @@ And in the AndroidManifest.xml file:
1229
1290
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
1230
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. |
1231
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. |
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`). |
1232
1295
  | **`twitter`** | <code>{ clientId: string; redirectUrl: string; defaultScopes?: string[]; forceLogin?: boolean; audience?: string; }</code> | |
1233
1296
  | **`facebook`** | <code>{ appId: string; clientToken?: string; locale?: string; }</code> | |
1234
1297
  | **`google`** | <code>{ iOSClientId?: string; iOSServerClientId?: string; webClientId?: string; mode?: 'online' \| 'offline'; hostedDomain?: string; redirectUrl?: string; }</code> | |
@@ -1239,35 +1302,71 @@ And in the AndroidManifest.xml file:
1239
1302
 
1240
1303
  Configuration for a single OAuth2 provider instance
1241
1304
 
1242
- | Prop | Type | Description | Default |
1243
- | ------------------------------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
1244
- | **`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. | |
1245
- | **`clientId`** | <code>string</code> | Alias for `appId` to match common OAuth/OIDC naming (`clientId`). If both are provided, `appId` takes precedence. | |
1246
- | **`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. | |
1247
- | **`authorizationBaseUrl`** | <code>string</code> | The base URL of the authorization endpoint | |
1248
- | **`authorizationEndpoint`** | <code>string</code> | Alias for `authorizationBaseUrl` (to match common OAuth/OIDC naming). | |
1249
- | **`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. | |
1250
- | **`accessTokenEndpoint`** | <code>string</code> | The URL to exchange the authorization code for tokens Required for authorization code flow | |
1251
- | **`tokenEndpoint`** | <code>string</code> | Alias for `accessTokenEndpoint` (to match common OAuth/OIDC naming). | |
1252
- | **`redirectUrl`** | <code>string</code> | Redirect URL that receives the OAuth callback | |
1253
- | **`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 | |
1254
- | **`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> |
1255
- | **`pkceEnabled`** | <code>boolean</code> | Enable PKCE (Proof Key for Code Exchange) Strongly recommended for public clients (mobile/web apps) | <code>true</code> |
1256
- | **`scope`** | <code>string \| string[]</code> | Default scopes to request during authorization | |
1257
- | **`scopes`** | <code>string[]</code> | Alias for `scope` using common naming (`scopes`). If both are provided, `scope` takes precedence. | |
1258
- | **`additionalParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in the authorization request | |
1259
- | **`loginHint`** | <code>string</code> | Convenience option for OIDC `login_hint`. Equivalent to passing `additionalParameters.login_hint`. | |
1260
- | **`prompt`** | <code>string</code> | Convenience option for OAuth/OIDC `prompt`. Equivalent to passing `additionalParameters.prompt`. | |
1261
- | **`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. | |
1262
- | **`additionalResourceHeaders`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional headers to include when fetching the resource URL | |
1263
- | **`logoutUrl`** | <code>string</code> | Custom logout URL for ending the session | |
1264
- | **`endSessionEndpoint`** | <code>string</code> | Alias for `logoutUrl` to match OIDC naming (`endSessionEndpoint`). | |
1265
- | **`postLogoutRedirectUrl`** | <code>string</code> | OIDC post logout redirect URL (sent as `post_logout_redirect_uri` when building the end-session URL). | |
1266
- | **`additionalLogoutParameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional parameters to include in logout / end-session URL. | |
1267
- | **`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. | |
1268
- | **`iosPrefersEphemeralSession`** | <code>boolean</code> | Alias for `iosPrefersEphemeralWebBrowserSession` (to match Capawesome OAuth naming). | |
1269
- | **`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> |
1270
- | **`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> |
1336
+
1337
+
1338
+ #### LinkedInProviderConfig
1339
+
1340
+ LinkedIn provider configuration (convenience wrapper around the generic OAuth2 provider).
1341
+
1342
+ Uses the OAuth2 engine with LinkedIn defaults:
1343
+ - Authorization URL: https://www.linkedin.com/oauth/v2/authorization
1344
+ - Token URL: https://www.linkedin.com/oauth/v2/accessToken
1345
+ - Resource URL: https://api.linkedin.com/v2/userinfo
1346
+ - Default scopes: `openid profile email`
1347
+
1348
+ | Prop | Type | Description |
1349
+ | ------------------ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1350
+ | **`clientId`** | <code>string</code> | LinkedIn Client ID from the LinkedIn Developer Portal. |
1351
+ | **`redirectUrl`** | <code>string</code> | Redirect URL that receives the OAuth callback. Must match a redirect URL configured in the LinkedIn Developer Portal. |
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. |
1353
+
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> |
1271
1370
 
1272
1371
 
1273
1372
  #### FacebookLoginResponse
@@ -1452,12 +1551,23 @@ Configuration for a single OAuth2 provider instance
1452
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> |
1453
1552
 
1454
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
+
1455
1565
  #### isLoggedInOptions
1456
1566
 
1457
- | Prop | Type | Description |
1458
- | ---------------- | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
1459
- | **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'oauth2' \| 'telegram'</code> | Provider |
1460
- | **`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') |
1461
1571
 
1462
1572
 
1463
1573
  #### AuthorizationCode
@@ -1470,10 +1580,10 @@ Configuration for a single OAuth2 provider instance
1470
1580
 
1471
1581
  #### AuthorizationCodeOptions
1472
1582
 
1473
- | Prop | Type | Description |
1474
- | ---------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------- |
1475
- | **`provider`** | <code>'apple' \| 'google' \| 'facebook' \| 'twitter' \| 'oauth2'</code> | Provider |
1476
- | **`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') |
1477
1587
 
1478
1588
 
1479
1589
  #### FacebookGetProfileResponse
@@ -1582,7 +1692,7 @@ Construct a type with a set of properties K of type T
1582
1692
 
1583
1693
  #### ProviderResponseMap
1584
1694
 
1585
- <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>; 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>
1586
1696
 
1587
1697
 
1588
1698
  #### GoogleLoginResponse
@@ -1590,9 +1700,52 @@ Construct a type with a set of properties K of type T
1590
1700
  <code><a href="#googleloginresponseonline">GoogleLoginResponseOnline</a> | <a href="#googleloginresponseoffline">GoogleLoginResponseOffline</a></code>
1591
1701
 
1592
1702
 
1703
+ #### LinkedInLoginResponse
1704
+
1705
+ LinkedIn login response (returned when using the LinkedIn convenience API).
1706
+
1707
+ <code><a href="#oauth2loginresponse">OAuth2LoginResponse</a></code>
1708
+
1709
+
1710
+ #### TikTokLoginResponse
1711
+
1712
+ TikTok login response (same shape as generic OAuth2).
1713
+
1714
+ <code><a href="#oauth2loginresponse">OAuth2LoginResponse</a></code>
1715
+
1716
+
1593
1717
  #### LoginOptions
1594
1718
 
1595
- <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: '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>
1720
+
1721
+
1722
+ #### LinkedInLoginOptions
1723
+
1724
+ LinkedIn login options (maps to the OAuth2 provider internally).
1725
+ `providerId` is set to `linkedin` automatically.
1726
+
1727
+ <code><a href="#omit">Omit</a>&lt;<a href="#oauth2loginoptions">OAuth2LoginOptions</a>, 'providerId'&gt;</code>
1728
+
1729
+
1730
+ #### Omit
1731
+
1732
+ Construct a type with the properties of T except for those in type K.
1733
+
1734
+ <code><a href="#pick">Pick</a>&lt;T, <a href="#exclude">Exclude</a>&lt;keyof T, K&gt;&gt;</code>
1735
+
1736
+
1737
+ #### Pick
1738
+
1739
+ From T, pick a set of properties whose keys are in the union K
1740
+
1741
+ <code>{
1596
1742
  [P in K]: T[P];
1597
1743
  }</code>
1744
+
1745
+
1746
+ #### Exclude
1747
+
1748
+ <a href="#exclude">Exclude</a> from T those types that are assignable to U
1749
+
1750
+ <code>T extends U ? never : T</code>
1598
1751
 
1599
1752
 
1600
1753
  #### Extract
@@ -1602,9 +1755,17 @@ Construct a type with a set of properties K of type T
1602
1755
  <code>T extends U ? T : never</code>
1603
1756
 
1604
1757
 
1758
+ #### RefreshTokenOptions
1759
+
1760
+ Options for `refreshToken()`.
1761
+ `providerId` is required for generic `oauth2` and ignored for LinkedIn and TikTok.
1762
+
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>
1764
+
1765
+
1605
1766
  #### LoginResult
1606
1767
 
1607
- <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: '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>
1608
1769
 
1609
1770
 
1610
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();