Add user authentication to the Flutter app using OAuth 2.0
Flutter is Google’s cross-platform UI toolkit created to build expressive and beautiful mobile applications.
OAuth 2.0 is an industry-standard protocol for authorization. It allow users to give third-party applications access to their resources. We can see a typical example of OAuth 2.0 in action when a user tries to sign up for a third-party app using Google. OAuth 2.0 allows users to give the third-party applications access to resources, such as using their profile data on a social network platform, without needing to input their credentials on said application.
You need the following installations in your machine:
- Flutter SDK: latest flutter SDK version
- A Development Environment, one of:
- Android Studio, or
- IntelliJ IDEA, or
- Visual Studio Code.
Scaffold a Flutter project
Once you are done with the installation, we need to create a flutter project.
Your Flutter project requires three main dependencies:
- http: A composable, Future-based library for making HTTP API call.
- flutter_appauth : A wrapper package around AppAuth for Flutter. AppAuth authenticates and authorizes users.
- fluttersecurestorage: A library used to securely persist data locally.
Configure Dependencies and Callback URL
A callback URL is a mechanism by which an authorization server communicates back to your applications.
Configure Android Dependencies and Callback URL
Update the android/app/build.gradle file as follows:
manifestPlaceholders = [