Fireship · @fireship

OAuth with Angular and Firebase Tutorial

Uploaded April 18, 2017 · Length 3:18

OAuth with Angular and Firebase Tutorial

Summary

build user authentication system with angular and firebase

  • angular authentication
  • firebase oauth
  • angular firebase tutorial
  • user login system
  • angular fire

Transcript preview

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

  1. 0:00

    in this episode we're going to build a

  2. 0:01

    user authentication system with angular

  3. 0:04

    4 and Firebase authentication is

  4. 0:07

    required in almost every angular

  5. 0:08

    application including this basic to-do

  6. 0:11

    list app the app currently has no

  7. 0:13

    authentication at all but we want the

  8. 0:15

    user to be able to log in with their

  9. 0:16

    Google Facebook Twitter or GitHub

  10. 0:20

    account at this point it is assumed that

  11. 0:23

    the angular fire two packages installed

  12. 0:25

    and bootstrapped in your app if not go

  13. 0:27

    to the docs or check out this

  14. 0:31

    [Music]

  15. 0:33

    [Applause]

  16. 0:35

    video we are going to keep this feature

  17. 0:37

    super simple the off service will handle

  18. 0:40

    all the interaction with the Firebase

  19. 0:42

    API the user login component will handle

  20. 0:45

    the log in and log out actions from the

  21. 0:48

    user and the user profile component will

  22. 0:51

    show details about the user that are

  23. 0:54

    returned from

  24. 0:57

    Firebase head over to your Firebase

  25. 1:00

    project and enable the providers you

  26. 1:02

    want to use for non-google providers you

  27. 1:04

    will need to get your own developer

  28. 1:06

    account and API

  29. 1:08

    [Music]

  30. 1:10

    Keys the way you handle authentication

  31. 1:12

    with Firebase is by subscribing to the

  32. 1:15

    angular fire off observable which

  33. 1:17

    returns a Firebase off State object now

  34. 1:22

    that we have the off State object we can

  35. 1:23

    take advantage of typescript accessors

  36. 1:26

    to get

  37. 1:28

    attributes

  38. 1:33

    here's the beauty of Firebase you can

  39. 1:35

    Implement four social off providers with

  40. 1:37

    very little code I start by creating a

  41. 1:40

    reusable private function that takes the

  42. 1:43

    provider as an argument called social

  43. 1:45

    sign

  44. 1:46

    in when a user attempts to sign in two

  45. 1:49

    things can happen success or failure

  46. 1:52

    when it's a success the thin code will

  47. 1:54

    execute and if it's a error the catch

  48. 1:57

    code will execute at this this point you