![]() In the authService.dart file, add the following block of code to import the dependencies for the application.įinal res = await fb.logIn(permissions: [ Now that we are all set, let’s get into coding! Creating the Auth service providers Import the dependencies Your app should now be able to access a Facebook profile.Under Permissions and Features request advanced access for the public profile.In the developer’s console dashboard, go to App review.Once you obtain the URL, head to the developer console under settings/basic, then paste the URL in the Privacy Policy URL field then, save. Follow this link to create a free privacy policy link. Paste the command below in your terminal:įor the Facebook login to function, you must include a link that specifies the privacy policy for your application. We need to generate a Development Key Hash.For the default activity name, use youp_packagename.MainActivity.In your AndroidManifest file, copy the package name of your app and paste it into the package name field.In the Facebook console, head over to the dashboard.Copy the OAuth redirect URI we need to set up our app with Facebook.Copy the App_id and Secret then, paste to the fields we left empty on the Facebook sign-in method.You will be redirected to a page showing the App_ID` and secret as shown below. In the dashboard, click basic under settings.Enter your App Name, Contact Email and App Purpose then, continue to create the app.Head over to Facebook Developer Console.We can obtain these from Facebook Developer Console. ![]() Under the project, select authentication, then enable Facebook and Google.You can follow this guide for the creation process. Create a new Firebase project if you don’t have one yet.The final project structure should look like this:įirebase is used as our database and to provide the Authentication API as well. These are the UI files rendered for the users. Next, create another folder called Screens and add two files login.dart, and homepage.dart in the folder. In this folder, create a file called authservice.dart to authorize logic for the application. In the lib folder create a folder called services. We will do most of the coding in the lib folder. You can follow this guide to create the new application. Project setupĬreate a new Flutter application. The home screen has a log out button the logs the user out and takes them to the login screen once more. Depending on the method a user chooses, the app calls a function to authorize the user and redirect him/her to a home screen where we display their name and profile image fetched from the social account selected. On the login screen, a user chooses whether to log in with Facebook or with Google. We will create two screens, one screen for logging in and the second screen as the home screen that can only be accessed once a user is authorized. A mobile emulator or a mobile device to test the project.Flutter SDK installed on your computer.A basic understanding of Flutter and Dart Language.In the end, a user should be able to login into the application by choosing either of the two from the login screen. We will build an authentication project in Flutter and implement social authentication using Facebook and Google. This article aims to guide the readers through a step-by-step understanding and implementation of social authentication in Flutter while narrowing it down to Google and Facebook. ![]() A programmer only needs to generate an SHA1 key and configure it with his/her machine. Google provides a platform for integrating social authentication with Firebase. Besides levying a user on constantly remembering multiple passwords, social authentication eases the registration process and improves security. Social authentication is an authentication technique in which one uses an existing account to log into or create a new account in another application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |