iOS Swift: Login
This tutorial demonstrates how to add user login to a Swift application using Auth0. 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
Add your credentials in the
Auth0.plist file. If the file does not exist in your project yet, create it:
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.
In your application's
Info.plist file, register your iOS Bundle identifier as a custom scheme:
Go to your Dashboard Settings and make sure that the Allowed Callback URLs field contains the following callback URL:
e.g. If your bundle identifier was com.company.myapp and your domain was company.auth0.com then this value would be
Start the Authentication
Universal Login is the easiest way to set up authentication in your application. We recommend using it for the best experience, best security and the fullest array of features.
If you are using Carthage, add the following to your
Custom DB Connections
If you are using Cocoapods, add the following to your
Add the Callback
For Auth0 to handle the authentication callback, update your
First, import the
Then, add the following
First, import the
Auth0 module in the file where you want to present the login page:
Then, present the login screen:
This adds the
profile scope to enable retrieving the User Profile.
After the user authenticates, their information is returned in a