iOS Objective-C Getting Started
This multistep quickstart guide will walk you through managing authentication in your iOS Objective-C apps with Auth0.
About the Sample Applications
Each step within this quickstart guide (starting with Login) contains a downloadable sample which demonstrates the topic being covered. Within each of these samples, you will find an appropriate application to demonstrate the features discussed in the chapter. All samples will use a Hybrid project (Objective-C & Swift). For more information, please check this guide from Apple.
Each tutorial will require you to use the Auth0.swift toolkit.
A brief description:
- Auth0.swift is a toolkit that lets you communicate efficiently with many of the Auth0 API functions and enables you to integrate the Login.
Create a Client
If you haven't already done so, create a new client application in your Auth0 dashboard and choose Native.
Adding Auth0 Credentials
The dependencies listed above require your client credentials in order for them to work. If you downloaded any sample project from here, these credentials are automatically set. Either way, you have to make sure they are there otherwise your app might crash.
Add your credentials in
Auth0.plist. You have to create that file if it doesn't already exist in your project:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>ClientId</key> <string>YOUR_CLIENT_ID</string> <key>Domain</key> <string>YOUR_AUTH0_DOMAIN</string> </dict> </plist>
Configure Callback URLs
Callback URLs are the URLs that Auth0 invokes after the authentication process. Auth0 routes your application back to this URL and appends additional parameters to it, including a token. Since callback URLs can be manipulated, you will need to add your application's URL to your client's Allowed Callback URLs for security. This will enable Auth0 to recognize these URLs as valid. If omitted, authentication will not be successful.
In your application's
Info.plist file, register your iOS Bundle Identifer as a custom scheme:
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>None</string> <key>CFBundleURLName</key> <string>auth0</string> <key>CFBundleURLSchemes</key> <array> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> </array> </dict> </array>
Finally, go to your Client's Dashboard and make sure that "Allowed Callback URLs" contains the following: