![]() ![]() ![]() If the App Store model and guidelines are not best for your app or business idea that’s okay, we provide Safari for a great web experience too. For everything else there is always the open Internet. We do this by offering a highly curated App Store where every app is reviewed by experts and an editorial team helps users discover new apps every day. In that directory, create package.The guiding principle of the App Store is simple-we want to provide a safe experience for users to get apps and a great opportunity for all developers to be successful. Our auth server would be a simple Express app with a single endpoint for logging the user in.Ĭreate a new directory and name it whatever you want, cometchat-auth-express, for example. ![]() In this tutorial we're assuming that we have registered a user in our app with that id, so make sure you fill the UID with the same value. ![]() To do that, log in to your CometChat account, and create a new app.įill in UID with "test-user-id" and Name with "Test User". So you'll create the CometChat user using the same id the user was registered with.īut in this tutorial, we'll skip all of this work and create it manually from the CometChat dashboard. And you'd typically do it when registering the user into your app. When building a real world app, you should create the user in CometChat programmatically. Let’s get started with building the example app. So it's important to generate a new auth token each time the user logs in to your app.Įnough theory for now. Note that when you call CometChat.logout() this auth token is destroyed. Lastly, return the logged-in user info along with the CometChat authToken.If the user was authenticated successfully to your app, use the same user id to create a new auth token for CometChat.In this step, we're doing a regular app authentication (not for CometChat). In the login endpoint, you should authenticate the user to your app using his or her username/password.We'll create the user manually from the dashboard.) When registering a new user in your app, create a new user in CometChat using the same user id in the database.Use that auth token to log the user in to CometChat using CometChat.login(authToken).If the user was authenticated successfully, the server should return the logged-in user object along with the auth token for logging in to CometChat.It's for logging the user in to your app.) Send a request to your backend server to log the user in using his or her username/password.Let's take a look at the workflow from the perspective of the frontend and the backend developers. CometChat's authentication workflowīefore we dive into writing code, let's learn the basic workflow of authenticating users to CometChat using auth tokens. In this tutorial we're going to learn how to use the auth token approach. Not only that, but also if the auth token’s owner has logged out, the auth token would become unusable as it would be deleted from CometChat’s servers. But with the auth token approach, the hacker would only be able to log in to the account that the auth token was created for. Because as you can imagine, if the hacker could get the secret key (by reverse engineering the client code for the example), the hacker would be able to log in to any CometChat account if the username is known. But in production, you should always go with the second approach as it's more secure since the secret key isn't used in it. If you're just testing things out, it's okay to use the first approach. The second approach is to log in using only the auth token that CometChat creates for you - CometChat.login(authToken). So it would look like this: CometChat.login(userUID, secret``Key``). The first approach is to use the user's UID and the auth-only secret key. There are two approaches to call this method. To log users in to CometChat you need to use the CometChat.login() method. So this means, you should authenticate users to your app and to CometChat. You still have to handle your app authentication yourself.Īuthenticating users to CometChat is necessary if you want them to use CometChat inside your app. CometChat isn't a user management solution for your app. It's important to know that authenticating users to CometChat is different that authenticating them to use your app. So in this tutorial, you'll create an example from scratch to learn the best way to integrate CometChat's authentication into your app. But when it comes to security, there are a few things to consider and learn to do authentication the right way. Logging users in to CometChat can be as easy as calling a single method. Users are required to log in to CometChat to be able to use it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |