#Stormpath is Joining Okta We are incredibly excited to announce that Stormpath is joining forces with Okta. Please visit the Migration FAQs for a detailed look at what this means for Stormpath users.
We're available to answer all questions at firstname.lastname@example.org.
Perfect Authentication Demo
- Username / Password Authentication
- Facebook / Google Login
- API Key authentication for API Endpoints
Install Swift via Swiftenv
If you haven't already, install Swift via Swiftenv.
$ git clone https://github.com/kylef/swiftenv.git ~/.swiftenv $ echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.bash_profile $ echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(swiftenv init -)"' >> ~/.bash_profile
Run the Example
$ swiftenv install $ swift build $ .build/debug/PerfectAuth
The application should run on port
8181 by default, so you should be able to access it from
The example code is commented and designed to be readable. Take a look through the code to see what it's doing!
Set up Facebook and Google Login
To learn more about Facebook and Google Login, check out the parent guide in the Turnstile documentation.
Create a Facebook Application
To get started, you first need to register an application with Facebook. After registering your app, go into your app dashboard's settings page. Add the Facebook Login product, and save the changes.
Valid OAuth redirect URIs box, type in your application's URL, postpended with
Create a Google Application
Add your application's URL, postpended with
/login/facebook/consumer to the
Authorized redirect URIs list. (eg,
Add your Client ID / Secret as Environment Variables
This example reads your Facebook and Google Client ID / Secret from environment variables, so you can make it portable. To add it to your application, first collect your Facebook / Google Client ID and Secret (sometimes called App ID), and set them as environment variables:
$ export FACEBOOK_CLIENT_ID=<Put Client ID here> $ export FACEBOOK_CLIENT_Secret=<Put Client Secret here> $ export GOOGLE_CLIENT_ID=<Put Client ID here> $ export GOOGLE_CLIENT_Secret=<Put Client Secret here>
This is also possible in Xcode under
Edit Scheme > Arguments > Environment Variables.
Now run the application. Facebook and Google login should work!
Note: Facebook / Google Login are broken in Swift 3.0 on Linux, because of a Foundation bug. This demo should work in
DEVELOPMENT-SNAPSHOT-2016-09-14-a or later, or in the official 3.0.1 release (not PREVIEW-1).
We're always open to contributions! Feel free to join the Stormpath slack channel to discuss how you can contribute!
Turnstile is built by Stormpath, an API service for authentication, authorization, and user management. If you're building a website, API, or app, and need to build authentication and user management, consider using Stormpath for your needs. We're always happy to help!