Identity Platform を使用してユーザーがメールアドレスでログインできるようにする
Identity Platform を使用してメールアドレスとパスワードでユーザーのログインを行う方法を学習します。
このタスクを Google Cloud コンソールで直接行う際の順を追ったガイダンスについては、「ガイドを表示」をクリックしてください。
始める前に
- Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオでの Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: Identity Platform Admin, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: Identity Platform Admin, Service Usage Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
Identity Platform を有効化
Google Cloud コンソールで、Cloud Marketplace の [Identity Platform] ページに移動します。
[IDENTITY PLATFORM を有効化] をクリックします。
メール ログインを構成する
[ID プロバイダ] ページに移動します。
[ID プロバイダ] ページで [プロバイダを追加] をクリックします。
[プロバイダの選択] リストで、 [メール / パスワード] を選択します。
[Enabled] をオンに切り替えます。
プロバイダの設定を保存するには、[保存] をクリックします。
ユーザーを作成する
Google Cloud コンソールで、[ユーザー] ページに移動します。
[ユーザーを追加] をクリックします。
[メール] フィールドにメールアドレスを入力し、下のフィールドにパスワードも入力します。後の手順で必要になるため、両方の値をメモします。
ユーザーを追加するには、[追加] をクリックします。新しいユーザーが [ユーザー] ページに表示されます。
ユーザーのログインを行う
ユーザーのログイン手順は、アプリが使用している SDK のバージョンによって異なります。
アプリケーションの正しい手順に従ってください。
SDK v9(モジュール式)
SDK をインストールして Firebase を初期化する
Firebase JS SDK バージョン 9 では、JavaScript モジュールの形式を使用します。
このワークフローでは npm を使用します。v9 SDK は、ツリー シェイキングで未使用コードを削除して SDK のサイズを小さくするために、モジュール バンドラと連携するように最適化されています。このため、モジュール バンドラまたは JavaScript フレームワーク ツールを使用する必要があります。
v9 SDK を使用するには、次の手順を行います。
プロジェクト ディレクトリから、npm を使用して Firebase をインストールします。