Auth0.swift Saving and Renewing Tokens
When an authentication is performed with the
offline_access scope included, it will return a Refresh Token that can be used to request a new user token, without asking for credentials again.
Auth0.swift provides a utility class to streamline the process of storing and renewing credentials. You can access the
idToken properties from the Credentials instance. This is the preferred method to manage user credentials.
First, import the
Next, present the Login:
It can be useful to perform a quick sanity check that you have valid credentials stored in the manager. If not the user can then be directed to authenticate.
Retrieving User Credentials
You can retrieve the user's credentials as follows:
Alternative Method - SimpleKeychain
If you are familiar with Lock v1, you may already be using the SimpleKeychain SDK to handle iOS Keychain read/write access. This section is for developers who would prefer to keep using the SimpleKeychain and not upgrade to the preferred Credentials Manager.
First thing you need to do is store the tokens you need. In this case, you will store the
refresh_token in the Keychain after a successful authentication.
Once you have those stored, you can at any point request a fresh Credentials instance.