Swiftpack.co - auth0/SimpleKeychain as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by auth0.
auth0/SimpleKeychain 1.0.0-fa
A Keychain helper for iOS to make it very simple to store/obtain values from iOS Keychain
⭐️ 406
🕓 9 hours ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/auth0/SimpleKeychain.git", from: "1.0.0-fa")


CircleCI Coverage Status Version License Platform

A wrapper to make it really easy to deal with iOS Keychain and store your user's credentials securely.

Key Features

  • Simple interface to store user's credentials (e.g. JWT) in the Keychain.
  • Store credentials under an Access Group to enable Keychain Sharing.
  • TouchID/FaceID integration with a reusable LAContext instance.

Table of Contents


  • iOS 9.0+ / macOS 10.11+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 12.x / 13.x
  • Swift 4.x / 5.x



If you are using Cocoapods, add this line to your Podfile:

pod "SimpleKeychain"

Then run pod install.

For more information on Cocoapods, check their official documentation.


If you are using Carthage, add the following line to your Cartfile:

github "auth0/SimpleKeychain"

Then run carthage bootstrap --use-xcframeworks.

For more information about Carthage usage, check their official documentation.


If you are using the Swift Package Manager, open the following menu item in Xcode:

File > Add Packages...

In the Search or Enter Package URL search box enter this url:


Then select the dependency rule and press Add Package.

For further reference on SPM, check its official documentation.


Save a JWT token or password

let jwt = // user's JWT token obtained after login
A0SimpleKeychain().setString(jwt, forKey: "auth0-user-jwt")

Obtain a JWT token or password

let jwt = A0SimpleKeychain().string(forKey: "auth0-user-jwt")

Share a JWT Token with other apps using iOS Access Group

let jwt = // user's JWT token obtained after login
let keychain = A0SimpleKeychain(service: "Auth0", accessGroup: "ABCDEFGH.com.mydomain.myaccessgroup")
keychain.setString(jwt, forKey: "auth0-user-jwt")

Store and retrieve a JWT token using TouchID/FaceID

Let's save the JWT first:

let jwt = // user's JWT token obtained after login
let keychain = A0SimpleKeychain()
keychain.useAccessControl = true
keychain.defaultAccessiblity = .whenPasscodeSetThisDeviceOnly
keychain.setString(jwt, forKey: "auth0-user-jwt")

If there is an existent value under the key auth0-user-jwt saved with AccessControl and A0SimpleKeychainItemAccessibleWhenPasscodeSetThisDeviceOnly, iOS will prompt the user to enter their passcode or fingerprint before updating the value.

Then let's obtain the value:

let message = NSLocalizedString("Please enter your passcode/fingerprint to login with awesome App!.", comment: "Prompt TouchID message")
let keychain = A0SimpleKeychain()
let jwt = keychain.string(forKey: "auth0-user-jwt", promptMessage: message)

Remove a JWT token or password

A0SimpleKeychain().deleteEntry(forKey: "auth0-user-jwt")

Remove all entries

Useful for testing.



Just clone the repo, run carthage bootstrap and you're ready to contribute!

What is Auth0?

Auth0 helps you to:

  • Add authentication with multiple sources, either social identity providers such as Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce (amongst others), or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS, or any SAML Identity Provider.
  • Add authentication through more traditional username/password databases.
  • Add support for linking different user accounts with the same user.
  • Support for generating signed JSON Web Tokens to call your APIs and flow the user identity securely.
  • Analytics of how, when, and where users are logging in.
  • Pull data from other sources and add it to the user profile through JavaScript rules.

Create a Free Auth0 Account

  1. Go to Auth0 and click Sign Up.
  2. Use Google, GitHub, or Microsoft Account to login.

Issue Reporting

If you have found a bug or to request a feature, please raise an issue. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.




This project is licensed under the MIT license. See the LICENSE file for more info.


Stars: 406
Last commit: 9 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Related Packages

Release Notes

9 hours ago

💡 Check the Migration Guide to understand the changes required to migrate your application to v1.


  • Drop support for old Swift versions [SDK-3444] #141 (Widcket)
  • Migrate to Swift [SDK-3428] #139 (Widcket)
  • Remove obsolete functionality [SDK-3419] #136 (Widcket)
  • Remove usage of deprecated properties [SDK-3414] #133 (Widcket)
  • Remove deprecated method [SDK-3413] #132 (Widcket)
  • Drop old platform versions [SDK-3387] #129 (Widcket)


  • Add support for custom attributes #153 (Widcket)
  • Add support for iCloud synchronization [SDK-3453] #146 (Widcket)


  • Replace OSX with macOS in schemes and targets #154 (Widcket)
  • Apply recommended Xcode 14 settings #143 (Widcket)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics