Google Login on Web
このプラグインのインストールステップと全マークダウンガイドを含む設定の質問をコピーする。
このガイドでは、GoogleログインとCapgoのWebアプリケーション用のソーシャルログインを設定する方法を学びます。 既に一般的な設定ガイドを読んだと想定しています。 Web上でのGoogleログインの使用.
Web上でのGoogleログインの使用は比較的簡単です。 使用するには、以下の手順を実行する必要があります。
GoogleコンソールでWebクライアントを作成する__CAPGO_KEEP_0__のインストール、同期、およびソースマークダウンガイドを含みます。
-
Using Google login on the web is rather simple. In order to use it, you have to do the following:__CAPGO_KEEP_0__
-
Click on the search bar
-
Search for
credentialsand click on theAPIs and Servicesoption (number 2 on the screenshot)
-
Click on the
create credentials
-
Select
OAuth client ID
-
Select the
Application typeasWeb application
-
Name your client and click
Create
-
Copy the client ID, you’ll use this as the
webClientIdin your application
-
-
Configure the web client in the Google Console
-
Please open the 資格情報ページ とWebクライアントをクリックしてください
-
ここで、
Authorized JavaScript originsあなたのアプリで使用する可能性のあるすべてのアドレスを含むように追加してください。私の場合は、localhostのみを使用しますが、カスタムポートを使用しているため、両方を追加する必要があります。 ONLY そしてhttp://localhostをクリックしてくださいhttp://localhost:5173-
Authorized JavaScript originsセクションのADD URIボタン
add URI
-
localhostのURLが入力されたADD URIダイアログ
-
Please repeat until you added all the URLs
-
完成したら、画面はこのようになります
-
-
ここで、以下のいずれかを追加してください
Authorized redirect URIsCapacitorSocialLogin プラグインを使用するページによって異なりますが、私の場合はhttp://localhost:5173/auth-
ここをクリックしてください
ADD URI
-
ADD URI ボタンをクリックしてください
ADD URLURL を入力して、
-
-
ADD URI ダイアログにリダイレクト URL を入力
save
-
-
下部の Web クライアント設定の "保存" ボタンをクリックしてください
loginfrom JavaScript like so:-
First, import
SocialLoginimport { SocialLogin } from '@capgo/capacitor-social-login'; -
Then, call initialize. This should be called ONLY once.
// onMounted is Vue specific// webClientId is the client ID you got in the web client creation step not the android client ID.onMounted(() => {SocialLogin.initialize({google: {webClientId: '673324426943-avl4v9ubdas7a0u7igf7in03pdj1dkmg.apps.googleusercontent.com',}})})
-
ログインボタンを作成して
SocialLogin.loginをクリックしたときにconst res = await SocialLogin.login({provider: 'google',options: {}})// Handle the responseconsole.log(JSON.stringify(res));
-
Googleログインから続けてください (Web)
セクションのタイトル:Googleログインから続けてください (Web)If you are using Google Login on Web to plan authentication and account flows, connect it with Using @capgo/capacitor-social-login for the native capability in Using @capgo/capacitor-social-login, @capgo/capacitor-social-login for the implementation detail in @capgo/capacitor-social-login, @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, and Two-factor authentication 2要素認証の実装詳細について。