Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sign In with Appleを実装してみた

Sign In with Appleを実装してみた

774a937b74096e82576b37678d00aeca?s=128

Daisuke Kishino

September 27, 2019
Tweet

Transcript

  1. 4JHO*OXJUI"QQMF Λ࣮૷ͯ͠Έͨ

  2. w "QQMF*%ͰΞΧ΢ϯτ࡞੒ɾϩάΠϯ͕Ͱ͖Δ w 5PVDI*%'BDF*%ͰೝূͰ͖Δ w ొ࿥͢ΔϝʔϧΞυϨεΛϥϯμϜʹͰ͖Δ 4JHO*OXJUI"QQMFͱ͸

  3. w4JHO*OXJUI"QQMF+4 w"VUIFOUJDBUJPO4FSWJDFT ωΠςΟϒ4%, ࣮૷खஈ͸̎ͭ

  4. wϒϥ΢βʹඈΜͩʢ6*8FC7JFXͷ৔߹ʣ wੜͷ6*8FC7JFXͩͱແ൓Ԡ ͱΓ͋͑ͣ+4൛Λ$PSEPWBʹຒΊࠐΉͱɾɾ

  5. w ೝূͷϞʔμϧ͕։͍ͨ w ͨͩɺ$PSEPWBͷ8FC7JFX಺ͩͱSFEJSFDUઌʹϖʔ δભҠͯ͠͠·͏ʢσΟʔϓϦϯΫͳΒ͍͚Δ͔΋ʣ w 69తʹ͸ωΠςΟϒ4%, ʢ"VUIFOUJDBUJPO4FSWJDFTʣͷํ͕Αͦ͞͏ 8L8FC7JFXͷ৔߹

  6. w 0QFO*%ϕʔεͬΆ͍ w ೝূͷϦΫΤετ͢ΔͱɺೝূϞʔμϧ͕දࣔ͞ΕΔ ʢ'BDF*%5PVDI*%ύεϫʔυͷԿΕ͔Ͱೝূʣ w औಘͰ͖Δ৘ใ͸*%5PLFOɺೝՄίʔυɺϝʔϧΞυ ϨεɺϢʔβʔ*%ɺϢʔβʔ໊ͳͲɻ "VUIFOUJDBUJPO4FSWJDFT

  7. return SignInWithApple.request({ requestedScopes: [ SignInWithApple.Scope.Email ], state: '...', nonce: '...',

    }).then((credential) => { // ... }).catch(error => { console.error(error) }) ೝূͷϦΫΤετ FNBJM OBNF͕ ࢦఆՄೳ $43'ରࡦ ϦϓϨΠ߈ܸରࡦ
  8. ͜Μͳײ͡ ৽نొ࿥ ϩάΠϯ

  9. ฦͬͯ͘Δ஋ { "authorizedScopes": [], "identityToken": "eyJr.....K9NQ", "authorizationCode": "c5704....eV6sg", "realUserStatus": 1,

    "fullName": { "namePrefix": null, "givenName": "Daisuke", "nameSuffix": null, "middleName": null, "familyName": "Kishino", "nickname": null }, "email": "XXX@privaterelay.appleid.com", "state": null, "user": "XXX" } *%5PLFO ೝՄίʔυ Ϣʔβʔ໊ ϝʔϧΞυϨε Ϣʔβʔ*% ࠷ॳͷճͷΈऔಘՄ
  10. αʔόʔଆ w ೝՄίʔυαʔόʔଆʹૹΔ w *%5PLFOͰ΋ྑ͍͕ɺϦϓϥΠ߈ܸ΍*%5PLFOͷݕূΛߟ͑Δͱɺ ೝՄίʔυͷํ͕҆શ w "QQMFͷUPLFOΤϯυϙΠϯτʹ౤͛ͯɺ*%5PLFOΛ औಘ w

    *%5PLFOͷॺ໊΍಺༰Λݕূͯ͠ɺ0,ͳΒձһొ࿥ ϩάΠϯ
  11. Ϣʔβʔ ΞϓϦ αʔόʔ "QQMF ϩάΠϯཁٻ ೝՄίʔυཁٻ ೝՄίʔυ ೝՄίʔυ ೝՄίʔυˍ DMJFOU@TFDSFU

    *%5PLFO *%5PLFOΛݕূ Ϣʔβʔ৘ใɺ τʔΫϯͳͲ "VUIFOUJDBUJPO4 FSWJDFT
  12. *%5PLFOͷ1BZMPBE { "iss": "https://appleid.apple.com", "aud": "jp.co.pscsrv.baassampleapp", "exp": 1569548110, "iat": 1569547510,

    "sub": “XXX", "at_hash": "dP9t…OBDPA", "email": "XXX@privaterelay.appleid.com", "email_verified": "true", "is_private_email": "true", "auth_time": 1569547508 "nonce": "XXX" } ൃߦऀ "QQMF ൃߦઌ "QQ ༗ޮظݶ ෼ ൃߦ࣌ؒ Ϣʔβʔ*% ೝՄίʔυͷ)BTI ϝʔϧΞυϨε ˢ͕ݕূࡁΈ͔ʁ ˢ͕1SJWBUF͔ʁ Ϣʔβʔೝূͷ࣌ࠁ ϦϓϥΠ߈ܸ ରࡦ༻ͷϥϯμϜ஋
  13. ஫ҙ఺ w ϝʔϧΞυϨε͸ॳճ͚ͩऔಘՄೳʢϢʔβʔ͕3FWPLF͢Δ ͱɺ࠶औಘՄೳʣ w Ϣʔβʔ໊͸UPLFOΤϯυϙΠϯτ͔Βฦͬͯ͜ͳ͍ ʢ"VUIFOUJDBUJPO4FSWJDFTܦ༝ͰͷΈऔಘՄೳʣ w DMJFOU@TFDSFU͸+85ʢ༗ޮظݶ࠷େ̒ϲ݄ʣ w

    1SJWBUFϝʔϧΞυϨε͸5FBN*%୯Ґʹ࡞੒͞ΕΔ w Ϣʔβʔ*%͸3FWPLF͞Εͯ΋มΘΒͳ͍ɻʢϝΞυ΋มΘΒͳ ͍ɻաڈͷهࣄͳͲݟΔͱมΘΔͱ͍͏هड़΋͋Δ͕ɾɾʣ
  14. $PSEPWBϓϥάΠϯͱαϯϓϧ w $PSEPWBϓϥάΠϯ w IUUQTHJUIVCDPNQTDTSWDPSEPWBQMVHJOBQQMFMPHJO w αϯϓϧʢΞϓϦଆʣ w IUUQTHJUIVCDPNQTDTSWDPSEPWBQMVHJOBQQMFMPHJO TBNQMF

    w αϯϓϧʢαʔόʔଆʣ w IUUQTHJTUHJUIVCDPNLJTIJOP GFDECEF