From the course: MongoDB Cloud Essential Training

Anonymous authentication

- [Narrator] In this course, we're going to be learning about Anonymous Authentication. Before we begin, let's go to Realm and let's go ahead and select our WAZOBIA application. So here, I'm just going to enter the Realm application that I created for the WAZOBIA application. I'm just going to take this all off and take this all off as well. Now, let's head to authentication and click that. If you take a closer look, you can see that MongoDB Realm allows you to authenticate your users in a variety of ways. You can authenticate your users anonymously with email, with Facebook, Google, Apple, API Keys. You can even use custom JWT Authentication to tie in a custom system. And if that doesn't work for you, you can use a custom function. Now in this particular video, we're not interested in all of them, but one. We're going to focus on Anonymous Authentication. Before we enable Anonymous Authentication, let me tell you a little bit about what Anonymous Authentication is. Anonymous Authentication is very common and you're probably using it without even realizing it. Anonymous Authentication provides app developers with a way to authenticate a user into a platform without collecting that user's information. Think about it this way. Let's say you create an application where you have a magazine and people come into that magazine and the read the magazine, but you don't create an account. You can create an anonymous user to represent that user and collect information like how many articles that person read, how long they spend reading that article that may be useful for you for analytics. Eventually, if the user then goes ahead and creates an account with the email and password, you can then merge or link these two authentication techniques, the anonymous and the email. This means that all that data that a user has generated before they gave you the email and password will stay intact. Now we're just going to enable this and click on, and then we're going to hit save draft. So, here we're just going to click next, next and just do that. So now we've just made a change. Whenever you make a change with MongoDB realm, you need to first of all deploy that change. So here you can see a blue bar here saying Review, Draft and Deploy. You can just hit Review, Draft and Deploy, and the MongoDB will show you some of the changes you've made. Now on screen here, you'll see something that looks like a JSON File that is showing you some of the changes or the deltas that you've made to a configuration file. This is a configuration file that works behind the scenes and you don't have to worry about it. You can even go ahead and give a particular deployment and name so that later on, you can go and track or roll back that deployment. At this point in time, we're not really interested in that. We're just going to click deploy, and then you're just going to wait for it to deploy changes. And then you can see that deployment was successful. And here you can go to deployment here and you can see all your deployments for your application. You can redeploy them or even like, go ahead and edit them. But we're not really interested in that. We're just going to go back to the Anonymous Authentication. Now, when you go back, you can see that the Anonymous Authentication is enabled. Now you might be asking, why did we enable Anonymous Authentication for the WAZOBIA application? Remember the whole idea of the WAZOBIA application is that people will be able to see the pictures of beautiful places around the world. So we don't want people to necessarily login with a username and password before they have access to see those beautiful pictures. We want them to still be able to come and just have access to the site. However, with Anonymous Authentication, we will still create a user for them. You can read more on Anonymous Authentication on the documentation. One thing worth knowing is that the Anonymous Authentication normally lasts around 90 days. So if that user hasn't necessarily authenticated into your system after 90 days, they automatically get deleted. There are a lot of uses for Anonymous Authentication, and you'll see how useful this particular authentication technique will be as we flesh out our WAZOBIA application in detail later on in this course.

Contents