Ionic Auth Connect の移行から @capgo/capacitor-social-login に続けてください。
このプラグインのインストール手順と完全なマークダウンガイドを含むセットアップコマンドをコピーしてください。
概要
概要セクションCapgo ソーシャルログインは、Google、Apple、Facebook、他社のアイデンティティプロバイダーをサポートするプロバイダーベースのOAuth2フローでIonic Auth Connectを置き換えます。
これが機能する理由
セクション「これが機能する理由」プラグインには、プロバイダーベースのOAuth2エンジンに親しみやすいIonic Auth ConnectプロバイダーのIDをマッピングするAuth Connect互換性のラッパーが含まれています。 SocialLoginAuthConnectプロバイダーのIDとして使用できるのは、 auth0, azure、 okta.
などです。
インストールbun add @capgo/capacitor-social-loginbunx cap syncクリップボードにコピー
インポートを置き換えます// Beforeimport { AuthConnect } from '@ionic-enterprise/auth-connect';
// Afterimport { SocialLoginAuthConnect } from '@capgo/capacitor-social-login';__CAPGO_KEEP_0__
__CAPGO_KEEP_1____CAPGO_KEEP_2__ __CAPGO_KEEP_3__ __CAPGO_KEEP_4__ __CAPGO_KEEP_5__ __CAPGO_KEEP_6__ __CAPGO_KEEP_7__ __CAPGO_KEEP_8__ __CAPGO_KEEP_9__ authConnect __CAPGO_KEEP_10__
await SocialLoginAuthConnect.initialize({ authConnect: { auth0: { domain: 'https://your-tenant.auth0.com', clientId: 'your-auth0-client-id', redirectUrl: 'myapp://oauth/auth0', audience: 'https://your-api.example.com', }, azure: { tenantId: 'common', clientId: 'your-azure-client-id', redirectUrl: 'myapp://oauth/azure', }, cognito: { domain: 'https://your-domain.auth.region.amazoncognito.com', clientId: 'your-cognito-client-id', redirectUrl: 'myapp://oauth/cognito', }, okta: { issuer: 'https://dev-12345.okta.com/oauth2/default', clientId: 'your-okta-client-id', redirectUrl: 'myapp://oauth/okta', }, onelogin: { issuer: 'https://your-tenant.onelogin.com/oidc/2', clientId: 'your-onelogin-client-id', redirectUrl: 'myapp://oauth/onelogin', }, },});__CAPGO_KEEP_12__
__CAPGO_KEEP_13__auth0azurecognitooktaonelogin
__CAPGO_KEEP_14__
__CAPGO_KEEP_15__const result = await SocialLoginAuthConnect.login({ provider: 'auth0',});
const status = await SocialLoginAuthConnect.isLoggedIn({ provider: 'auth0',});
const code = await SocialLoginAuthConnect.getAuthorizationCode({ provider: 'auth0',});
await SocialLoginAuthConnect.logout({ provider: 'auth0',});__CAPGO_KEEP_17__
プロバイダ固有のプリセット例Auth0 プリセット例
Auth0 プリセット例await SocialLoginAuthConnect.initialize({ authConnect: { auth0: { domain: 'https://your-tenant.auth0.com', clientId: 'your-auth0-client-id', redirectUrl: 'myapp://oauth/auth0', audience: 'https://your-api.example.com', }, },});
const auth0Result = await SocialLoginAuthConnect.login({ provider: 'auth0',});
console.log(auth0Result.result.idToken);Azure プリセット例
Azure プリセット例await SocialLoginAuthConnect.initialize({ authConnect: { azure: { tenantId: 'common', clientId: 'your-azure-client-id', redirectUrl: 'myapp://oauth/azure', }, },});
const azureResult = await SocialLoginAuthConnect.login({ provider: 'azure',});
console.log(azureResult.result.resourceData);Cognito プリセット例
Cognito プリセット例await SocialLoginAuthConnect.initialize({ authConnect: { cognito: { domain: 'https://your-domain.auth.region.amazoncognito.com', clientId: 'your-cognito-client-id', redirectUrl: 'myapp://oauth/cognito', }, },});
const cognitoResult = await SocialLoginAuthConnect.login({ provider: 'cognito',});
console.log(cognitoResult.result.idToken);Okta プリセット例
Okta プリセット例await SocialLoginAuthConnect.initialize({ authConnect: { okta: { issuer: 'https://dev-12345.okta.com/oauth2/default', clientId: 'your-okta-client-id', redirectUrl: 'myapp://oauth/okta', }, },});
const oktaResult = await SocialLoginAuthConnect.login({ provider: 'okta',});
console.log(oktaResult.result.resourceData);OneLogin presetの例
OneLogin presetの例のセクションawait SocialLoginAuthConnect.initialize({ authConnect: { onelogin: { issuer: 'https://your-tenant.onelogin.com/oidc/2', clientId: 'your-onelogin-client-id', redirectUrl: 'myapp://oauth/onelogin', }, },});
const oneloginResult = await SocialLoginAuthConnect.login({ provider: 'onelogin',});
console.log(oneloginResult.result.idToken);エンドポイントのオーバーライド
エンドポイントのオーバーライドのセクション各プリセットは domain または issuer。あなたのテナントがカスタムエンドポイントを使用している場合、直接オーバーライドしてください:
await SocialLoginAuthConnect.initialize({ authConnect: { onelogin: { issuer: 'https://your-tenant.onelogin.com/oidc/2', clientId: 'your-onelogin-client-id', redirectUrl: 'myapp://oauth/onelogin', authorizationBaseUrl: 'https://your-tenant.onelogin.com/oidc/2/auth', accessTokenEndpoint: 'https://your-tenant.onelogin.com/oidc/2/token', resourceUrl: 'https://your-tenant.onelogin.com/oidc/2/me', logoutUrl: 'https://your-tenant.onelogin.com/oidc/2/logout', }, },});直接OAuth2の設定
直接OAuth2の設定のセクション__CAPGO_KEEP_0__のプリセットを使用しない場合は、一般的なOAuth2ドキュメントで直接プロバイダを設定してください:
移行に関する注意
タイトル「移行に関する注意」-
互換性レイヤーはOAuth2ベースです プロバイダの名前は、Ionicのネイティブ実装の詳細を保持します。
-
リフレッシュトークンはスコープに依存しています リクエスト
offline_accessまたは、リフレッシュトークンが必要な場合にプロバイダ固有のエクイバレントを使用してください。 -
カスタムエンドポイントはプリセットを上書きできます プリセットが近いですが、正確ではありません。上書きするエンドポイントは、異なる部分のみを上書きしてください。
-
直接
oauth2エントリが勝つ あなたが両方の定義を設定した場合authConnect.auth0そしてoauth2.auth0、oauth2直接
configが優先される
関連するドキュメントKeep going from Ionic Auth Connect Migration to @capgo/capacitor-social-login
「Ionic Auth Connect マイグレーションから @capgo/capacitor-social-login」まで続ける」あなたが使用している場合 Ionic Auth Connect マイグレーションから @capgo/capacitor-social-login 認証とアカウントフローの計画に使用し、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-social-login @capgo/capacitor-social-loginを使用 @capgo/capacitor-social-loginのネイティブ機能 @capgo/capacitor-social-loginの実装詳細 @capgo/capacitor-passkey @capgo/capacitor-passkeyの実装詳細 @capgo/capacitor-native-biometric @capgo/capacitor-native-biometricの実装詳細 @capgo/capacitor-native-biometric 2要素認証 2要素認証の実装詳細について