Fireship · @fireship

Firebase Google SignIn + Firestore w/ Angular

Uploaded January 11, 2019 · Length 11:13

Firebase Google SignIn + Firestore w/ Angular

Summary

Implement Google OAuth via Firebase in an Angular app, saving custom user data in Firestore and enabling full-stack security.

  • firebase google sign in
  • angular firebase
  • firestore database
  • full stack security
  • google oauth
  • angular services
  • rxjs operators

Transcript preview

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

  1. 0:00

    a single most important feature for many

  2. 0:08

    apps is the user authentication system

  3. 0:10

    if you don't have a good way to sign-in

  4. 0:12

    users and observe their data it's hard

  5. 0:14

    to build out anything else in today's

  6. 0:16

    video we'll implement Google OAuth via

  7. 0:18

    firebase in an angular app in addition

  8. 0:20

    we'll save custom information about the

  9. 0:22

    user in the firestore database and we'll

  10. 0:24

    implement full stack security on both

  11. 0:26

    the front end and the back end so by the

  12. 0:28

    end of this video you should have a

  13. 0:29

    solid off system that you can build on

  14. 0:31

    if you're new here like and subscribe

  15. 0:33

    and you can find the full source code on

  16. 0:34

    fire ship io and I'd like to quickly

  17. 0:37

    point out that this is the first episode

  18. 0:39

    with the new fire ship io channel name

  19. 0:41

    but this video is actually a revision of

  20. 0:43

    episode 55 from angular firebase over

  21. 0:45

    the next few months I'll be revising and

  22. 0:47

    updating a lot of that content so if

  23. 0:49

    there's anything you want to see me

  24. 0:50

    revisit let me know in the comments to

  25. 0:52

    get started with this lesson you'll need

  26. 0:53

    to have an angular app with angular fire

  27. 0:55

    and firebase installed you can find full

  28. 0:57

    instructions for that on the main lesson

  29. 0:59

    page first we'll go into our firebase

  30. 1:01

    project and under the authentication tab

  31. 1:03

    we'll enable the Google sign-in method

  32. 1:05

    from there we'll go ahead and enable

  33. 1:07

    fire store and for now we'll leave the

  34. 1:09

    security rules unlocked but we'll circle

  35. 1:11

    back around to this at the end of the

  36. 1:12

    video to secure the backend when we sign

  37. 1:15

    in a user with firebase it's going to

  38. 1:16

    create this authentication record but

  39. 1:18

    it's very limited and we can't easily

  40. 1:20

    customize it the important thing that it

  41. 1:22

    gives us is a unique user ID which we

  42. 1:24

    can use to model relational data in fire

  43. 1:26

    store for example you might have a has

  44. 1:29

    one relationship where a user has an

  45. 1:30

    account and we can easily model that in

  46. 1:32

    the database by just giving the document

  47. 1:34

    itself the same user ID as the

  48. 1:36

    authentication record now we'll jump

  49. 1:38

    into angular and write some code that

  50. 1:39

    can read write and react to this data in

  51. 1:41

    real time your user authentication logic

  52. 1:44

    and state is something that you'll be

  53. 1:46

    managing globally so you'll want to have

  54. 1:48

    it organized as an angular service so we

  55. 1:50

    can go ahead and generate it with the

  56. 1:52

    angular CLI by running ng generate

  57. 1:54

    service and I'm putting it inside of a

  58. 1:56

    services directory now before we get

  59. 1:59

    into the service itself there's one