Play 2 Scala
This tutorial demonstrates how to add user login to a Scala Play application. We recommend you to Log in to follow this quickstart with examples configured for your account.
I want to integrate with my app15 minutes
I want to explore a sample app2 minutes
Get a sample configured with your account settings or check it out on Github.
Get Your Application Keys
When you signed up for Auth0, a new application was created for you, or you could have created a new one.
You will need some details about that application to communicate with Auth0. You can get these details from the Application Settings section in the Auth0 dashboard.
You need the following information:
- Client ID
- Client Secret
Configure Callback URLs
A callback URL is a URL in your application where Auth0 redirects the user after they have authenticated.
The callback URL for your app must be whitelisted in the Allowed Callback URLs field in your Application Settings. If this field is not set, users will be unable to log in to the application and will get an error.
Configure Logout URLs
A logout URL is a URL in your application that Auth0 can return to after the user has been logged out of the authorization server. This is specified in the
returnTo query parameter.
The logout URL for your app must be whitelisted in the Allowed Logout URLs field in your Application Settings. If this field is not set, users will be unable to log out from the application and will get an error.
client_metadata with the Management API
Configure Scala to Use Auth0
Create applications with
Add the Auth0 Callback Handler
Add the handler for the Auth0 callback so you can authenticate the user and retrieve their information:
client_metadata properties in the dashboard
Application controller add
login action to log the user in.
index view add a link to
Display User Information
You can access the user information from the
Display the user information in the
To log the user out, you have to clear the data from the session, and redirect the user to the Auth0 logout endpoint. You can find more information about this in our documentation logout documentation.
logout action in the
user view add a link to
You can add the following
Action to check if the user is authenticated. If not, redirect them to the login page: