
Learn to authenticate users and manage a MongoDB-backed user database on a Ktor server, enabling secure Android communication with the Bacon server and practical JWT, OpenID Connect, and token concepts.
Explain the secure Google OAuth authentication flow for an Android client and a Ktor server, including exchanging a token id via http post, offline jwt verification, and session cookies.
Learn the difference between authentication and authorization, where authentication verifies who you are and authorization governs access, using ID tokens, access tokens, and the OpenID Connect and OAuth frameworks.
Understand how ID tokens from OpenID Connect prove user authentication and enable secure access to server endpoints through JWT claims like audience and issuer.
Explain how an access token enables delegated authorization to access user resources, with scopes defining allowed actions, and secure JWTs kept confidential among the app, authorization server, and resource server.
Learn how oauth 2.0 delegates user authentication to service providers and issues access tokens with scopes. Discover OpenID Connect as an identity layer that delivers ID tokens (JWT) for sign-on.
Explore JSON web tokens (JWT), an open standard for securely transmitting information, detailing header, payload, and signature, and explain information exchange and authorization uses with signing algorithms.
Learn how a server-side session ID is issued after verifying a Google ID token to authenticate users, authorize access to protected endpoints, and how cookies handle client-side data.
Implement one tap sign in for Android with the Google One Tap API, using the bottom sheet to list connected accounts and configuring filter by authorized accounts.
Android Application
https://github.com/stevdza-san/GoogleAuthApp
Ktor Server
https://github.com/stevdza-san/GoogleAuthServer
Source code: https://github.com/stevdza-san/GoogleAuthApp
Preview the two-screen Android design—login and profile—with dark and light themes, one-tap Google sign-in, and custom ui components, updating first and last name on a backend MongoDB via Ktor.
Connect to Google Cloud Platform to generate client API keys and configure credentials for Android and web, including OAuth client IDs and the SHA-1 certificate fingerprint.
Create a navigation package and sealed screen class with login and profile routes; set start destination to login and configure a remember nav controller in main activity.
Set up Dagger-Hilt by creating an application class annotated with Hilt Android App, and build a network module to provide singleton OkHttp client, Retrofit, cookie manager, and JSON converter.
Create a custom Google button as a composable with idle text signing with Google and loading state please wait, featuring an icon, shape, border, and a circular progress indicator.
Design a Jetpack Compose message bar that animates from top to bottom to show error or success messages via MessageBarState (message and exception), handling socket timeout and connect exceptions.
Build a login screen in an android app using Jetpack Compose, featuring a top bar, a message bar, Google sign-in button, and a reusable login content with state handling.
Implement data store operations and a repository to persist and read a boolean sign-in state using a data store preference and a flow-based read.
Configure the repository module by providing a data store preferences, data store operations, and repository implementation via dependency injection, linking Android data store with the repository.
Develop and observe a login view model that manages sign-in state and message state using a repository and data store, enabling the login screen to reflect persistent sign-in changes.
Implement two Android one-tap authentication functions—sign in and sign up—using Google ID tokens, server client IDs, and account filtering to streamline sign-in.
Implement start activity for result in Jetpack Compose using remember launcher for activity result to handle one tap sign-in. Extract credentials and token ID to send to the backend server.
Implement and demonstrate one-tap Google sign-in to retrieve a token ID on the login screen, update sign-in state, handle account not found errors, and decode the JWT to inspect claims.
Source code: https://github.com/stevdza-san/GoogleAuthServer
Install and test a root route and endpoints in a Ktor backend using Postman. Run the application class to start the server and view the welcome message.
Install and configure a server-side session plugin, verify Google token ID, store user data on the server, and issue a cookie-based session for the Android app.
Install and configure the authentication plugin in a Ktor server to authorize endpoints using a session, create an unauthorized route, and redirect unauthenticated users to that endpoint.
Create an authorized route that authenticates users, establishes a session cookie, and returns a serialized API response for secured endpoints in a Ktor server.
Verify the token ID using Google ID token verifier with audience and issuer checks, parsing an API request containing the token ID and returning a verified token or unauthorized.
Compare relational school databases with NoSQL, learn how MongoDB stores data as documents in JSON-like BSON, with flexible schemas, and explore Atlas and the MongoDB campus.
Download the MongoDB community server and install it locally, then open MongoDB campus to interact with your databases. When deploying on Heroku later, switch to MongoDB Atlas.
Watch the last section of this course so you can check out the newest update about Koin plugin. We no longer need to use a custom plugin with Ktor 2.0+
Define a user data model with id, name, email, profile photo, and implement a MongoDB based user data source with get by id, save, delete, and update operations.
Verify Google token ID, save user to MongoDB via a data source, and establish a session, with duplicate checks to avoid re-adding existing users.
Implement the get user info route with token verification to fetch the user's id and name from the server database via the user data source, populating the Android profile screen.
Create the update user info route to let authorized Android clients update a user's first and last name in MongoDB, using Ktor server, authentication, and a user update data model.
Create a secure delete user route on a Ktor server to remove authenticated users from MongoDB, handling sessions and API responses.
Implement a sign out route to clear the user session, return a success API response with status OK, and delete the session cookie in a Ktor server backed by MongoDB.
Create a Ktor API interface for the Android app, defining endpoints for token verification, get user info, update user, delete user, and clear session with retrofit.
Implement repository methods to interact with the Occator API by adding suspend functions for verify token, get user, update user, delete user, and clear session.
Verify the token ID from Android sign-in against a Ktor backend and MongoDB, handling loading, success, and error states to navigate to profile.
Create the profile screen top bar with a title and two actions, including a save action and a delete account dropdown, implemented as composable functions for the profile screen.
Learn to display an alert dialog in a profile screen using a composable, wiring a delete account action with an open dialogue state and yes/no choices.
Design and implement the profile screen in an Android app using compose, with a loading indicator, message bar, and editable first name, last name, and email address fields.
Fetch user data from the backend to populate the profile screen by implementing a profile view model that retrieves first name, last name, and email from MongoDB, handling API responses.
Update user information from the Android app via the profile view model by validating fields and sending updates to the backend server and MongoDB, with loading indicator and success message.
Implement a one-tap sign-out in an Android app, clearing the server session and navigating to the login screen, with an updated profile view model and robust loading and error handling.
Implement the delete user flow in the Android app, updating session and API responses, handling errors, and navigating back to login after removing the user from MongoDB on the server.
Implement session removal handling by verifying tokens after unauthorized responses, re-authenticating, and reissuing sessions to keep secure access between Android client and Ktor server.
configure window soft input mode adjust resize to prevent keyboard overlap and ensure field interaction; create a night mode themes.xml to apply a black status bar for dark theme.
Deploy your Android server to Heroku, configure Gradle and Python build packs, connect MongoDB Atlas via environment variables, and push via GitHub while debugging logs to ensure a running app.
Connect your Android app to a cloud MongoDB Atlas database by configuring the Atlas cluster, obtaining a connection string, and setting it as a Heroku environment variable on the server.
Explore how insecure http on a local host exposes tokens and user data by inspecting network traffic with Wireshark and pcap, and learn how https preserves privacy.
Migrate the Android app to coil async image loading with data, crossfade, placeholders, and a circle crop transformation. Refresh dependencies and fix deprecated retrofit usage, then run the app.
Update #2 updates server dependencies and performs code cleanup, introducing a call logging package and replacing the custom plugin with the Koin library, ensuring the server compiles.
In this course I'm going to teach you how to successfully authenticate your users, and create you own user database on the back-end server, all by yourself. This course project will include a Mongo DB on our back-end, where you'll learn how to execute all CRUD operations from an Android application.
You don't need a Firebase anymore, because with this course you'll get the necessary knowledge to establish a secure communication between your Android application and the back-end server. At the start of this course I will introduce you with some important concepts which we are going to use throughout this course, like the difference between Authentication and Authorization, ID Token and Access Token, OAuth and Open ID Connect, Sessions and Cookies, JSON Web Token and One-Tap Sign in for Android.
You will be able to see how that communication will look like behind the scenes, and we are going authenticate our users using their Google account. In Android app, as a new sign in mechanism, One-Tap for Android will be implemented as well.
We will create a rather simple project, so that you can easily follow up this course, and learn everything you need, that later you become qualified to create more complex applications, that include authenticate mechanism and your own user database.
We are going to use the newest technologies and API's in this project like: Jetpack Compose, Ktor 2.0, One-Tap Sign in for Android and Mongo DB.