Sign In with Apple を Web に実装 – Apple Developer での設定
WWDC19 で発表された Sign In with Apple。今回はいち早く Web に実装してみたので、記録として残しておきます。
App ID Capabilities の設定
まずは Certificates, Identifiers & Profiles にアクセスして、Identifiers を選びます。Sign In with Apple を有効にしたい App Identifier を選び、Capabilities の中の Sign In with Apple にチェックを入れて Save します。
Services ID の作成
続いて、先程の Certificates, Identifiers & Profiles の Identifiers から + ボタンをクリックし、Services ID を作成します。Services IDs を選択して Continue します。
続いて、Web サイトの Description と Identifier を決めて入力し、Sign In with Apple の enabled にチェックを入れ、Edit をクリックします。
Sign In with Apple を有効にした App ID を Primary App ID として選び、ドメインとリダイレクト URL を入力します。リダイレクト URL は最大10個までとのこと。入力を終えたら Save して Continue します。
入力した内容に間違いがないか確認をして、Register します。
Web ドメインの認証
次に Web ドメインの認証をします。Certificates, Identifiers & Profiles の Identifiers から右側にあるメニューから Services IDs を選び、先ほど作成した Services ID を選びます。
Configure をクリックします。
Download をクリックして apple-developer-domain-association.txt をダウンロードし、指定された場所にアップロードしておきます。
入力したドメインが「tret.jp」なら、https://tret.jp/.well-known/apple-developer-domain-association.txt とします。ブラウザでアップロードした apple-developer-domain-association.txt にアクセスできたら、Verify をクリックして認証します。
Return URLs の入力されているフィールドのとなりの Add も忘れずにクリックして、Save して Continue します。入力した内容に間違いがないか確認をして、Save をクリックします。
以上で Apple Developer での作業は終了となります。
Web でのサンプルコード
実際に Web でサインインするサンプルコードはこちらから。
Sign In with Apple を Web に実装 – サンプルコード