Fireship · @fireship

Sign in with Apple from a Firebase Web App

Uploaded February 10, 2020 · Length 1:50

Sign in with Apple from a Firebase Web App

Summary

Implement Apple sign-in with Firebase in a web app using Apple Developer account and private key.

  • apple sign in
  • firebase authentication
  • firebase web app
  • apple developer account
  • private key

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    sign-in with Apple was a feature

  2. 0:01

    announced by Apple and 2019 and it

  3. 0:04

    allows users to authenticate into a web

  4. 0:06

    or mobile application using their Apple

  5. 0:08

    ID it works just like other one-click

  6. 0:10

    social sign-in methods like Google

  7. 0:11

    Facebook Twitter etc to implement this

  8. 0:14

    method in your firebase app you'll first

  9. 0:16

    need to have an Apple Developer account

  10. 0:17

    which will run you about $99 per year

  11. 0:19

    now head over to your Apple developer

  12. 0:21

    portal create a new app ID or update an

  13. 0:24

    existing one to use the sign-in with

  14. 0:26

    Apple capability from there you'll

  15. 0:28

    create a new service ID and configure it

  16. 0:30

    to work with your domain enter the

  17. 0:32

    hosting URLs from your firebase project

  18. 0:34

    then register the service ID now we need

  19. 0:36

    to verify ownership of this domain with

  20. 0:38

    Apple go back to the configuration for

  21. 0:40

    the service ID you'll see the option to

  22. 0:42

    download a file save that file under the

  23. 0:45

    well-known directory in your public

  24. 0:46

    hosting folder then upload this file to

  25. 0:49

    firebase hosting by running firebase

  26. 0:50

    deploy from the command line click

  27. 0:52

    verify and you should get a green check

  28. 0:54

    mark now the last thing we need is a

  29. 0:56

    private key click on keys and then

  30. 0:58

    generate a new one for Apple sign-in go

  31. 1:00

    ahead and download this file somewhere

  32. 1:01

    securely on your system then open it in

  33. 1:03

    your editor at this point we can go to

  34. 1:05

    the authentication tab on the firebase

  35. 1:07

    console and click enable for Apple

  36. 1:09

    sign-in enter your team ID as well as

  37. 1:11

    the information from the private key and

  38. 1:13

    now we just need to add a little bit of

  39. 1:15

    JavaScript to our front-end app with

  40. 1:16

    firebase initialized we'll make a

  41. 1:18

    reference to auth then we'll define an

  42. 1:20

    async function called sign in with Apple

  43. 1:22

    it instantiates an auth provider for

  44. 1:24

    apple calm then awaits the auth sign in

  45. 1:26

    with pop-up method this prompts the user

  46. 1:28

    to login with their Apple ID and when

  47. 1:30

    they're done they'll be logged into the

  48. 1:32

    firebase app and will have access to

  49. 1:34

    their user data on the result this has

  50. 1:36

    been Apple sign-in with firebase in 100

  51. 1:38

    seconds and I realize that was super

  52. 1:39

    fast so head over to fire ship IO to get

  53. 1:42

    a full step-by-step breakdown of the

  54. 1:43

    process thanks for watching make sure to

  55. 1:45

    LIKE and subscribe and I will see you in

  56. 1:47

    the next one