Kotlin Quickstart
This guide will only include the frontend integration. If you would like to also handle Session Management in your backend, select your backend technology below:
This is a quickstart guide to help you integrate Descope with your Kotlin application. Follow the steps below to get started.
Add the Descope Package
Next, we need to add the Descope Kotlin SDK as a dependency.
- Within Android Studio, go to File > Project Structure > Dependencies > Add Dependency > Library Dependency
- Search for the dependency: "com.descope"
- Configure your desired dependency rules
- Click "Ok"
Import the Kotlin SDK
Next step is to import the Descope Kotlin dependency
Configure Descope with a custom Project ID
Configure Descope in the MainActivity
class. A Descope Project ID is required to initialize the SDK. You can find this ID on the project page in the Descope Console.
Note
You can also add the optional baseUrl
parameter if you're utilizing a CNAME within your Descope project (ex: https://auth.company.com
).
Define and host your flow
Before we can run a flow, it must first be defined and hosted. Every project comes with predefined flows out of the box, found in your Descope console. You can customize your flows to suit your needs and host it. Essentially, you'll need the URL where your authentication flow is separately hosted on the web (eg. https://example.com/login
).
Run your Flow
After completing the prerequisite steps, it is now possible to run a flow.
The flow will run in a dedicated DescopeFlowView
which receives
a DescopeFlow
object. The DescopeFlow
objects defines all of the options available when running a flow.
Read the class documentation for a detailed explanation.
The flow needs to reside in your UI in some form, and to start it, call the run()
function
Note
If you need to support Magic Link redirects, follow the steps in our README.
Utilize the Kotlin SDK Session Management Functions
Descope provides the sessionManager to check if the user is authenticated or get user data such as email, userId, etc. You can use these to customize the user experience:
isAuthenticated
- is user authenticated?user
- user object that contains all user attributes (email, name, etc.)me
- updates the managed session user details and returns itlogout
- logs the user out by revoking the active session and clearing it from the session manager storage
At this point, you're done with the frontend. If you'd like more detail into frontend Session Management, check out our SDK. If you would like to also handle Session Validation in your backend, keep on reading!
Continue with Backend SDK
If you would like to also handle Session Management in your backend, keep on reading by selecting your backend technology below:
Checkpoint
Your application is now integrated with Descope. Please test with sign-up or sign-in use case.
Customize
Now that you have the end-to-end application working, you can choose to configure and personalize many different areas of Descope, including your brand, style, custom user authentication journeys, etc. We recommend starting with customizing your user-facing screens, such as signup and login.