{"id":21980570,"url":"https://github.com/stormpath/stormpath-sdk-ios","last_synced_at":"2025-08-02T03:39:32.519Z","repository":{"id":62456104,"uuid":"46089201","full_name":"stormpath/stormpath-sdk-ios","owner":"stormpath","description":"iOS SDK for Stormpath","archived":false,"fork":false,"pushed_at":"2017-03-06T17:16:48.000Z","size":466,"stargazers_count":26,"open_issues_count":7,"forks_count":13,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-07-03T01:47:53.221Z","etag":null,"topics":["facebook","github","google","ios","linkedin","login","oauth","stormpath"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stormpath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-13T00:17:37.000Z","updated_at":"2023-11-03T14:35:39.000Z","dependencies_parsed_at":"2022-11-01T23:46:34.273Z","dependency_job_id":null,"html_url":"https://github.com/stormpath/stormpath-sdk-ios","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/stormpath/stormpath-sdk-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormpath%2Fstormpath-sdk-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormpath%2Fstormpath-sdk-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormpath%2Fstormpath-sdk-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormpath%2Fstormpath-sdk-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stormpath","download_url":"https://codeload.github.com/stormpath/stormpath-sdk-ios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stormpath%2Fstormpath-sdk-ios/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268331584,"owners_count":24233293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facebook","github","google","ios","linkedin","login","oauth","stormpath"],"created_at":"2024-11-29T17:12:03.879Z","updated_at":"2025-08-02T03:39:32.488Z","avatar_url":"https://github.com/stormpath.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Stormpath is Joining Okta\nWe are incredibly excited to announce that [Stormpath is joining forces with Okta](https://stormpath.com/blog/stormpaths-new-path?utm_source=github\u0026utm_medium=readme\u0026utm-campaign=okta-announcement). Please visit [the Migration FAQs](https://stormpath.com/oktaplusstormpath?utm_source=github\u0026utm_medium=readme\u0026utm-campaign=okta-announcement) for a detailed look at what this means for Stormpath users.\n\nWe're available to answer all questions at [support@stormpath.com](mailto:support@stormpath.com).\n\n# Stormpath iOS SDK\n\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Stormpath.svg?style=flat)](http://cocoapods.org/pods/Stormpath)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/stormpath/stormpath-sdk-ios)\n[![License](https://img.shields.io/cocoapods/l/Stormpath.svg?style=flat)](http://cocoapods.org/pods/Stormpath)\n[![codebeat badge](https://codebeat.co/badges/6b76c7c6-f924-40f6-8ce0-42d165cf6a17)](https://codebeat.co/projects/github-com-stormpath-stormpath-sdk-ios)\n[![Slack Status](https://talkstormpath.shipit.xyz/badge.svg)](https://talkstormpath.shipit.xyz)\n\nThe iOS SDK for [Stormpath](https://stormpath.com/), a framework for authentication \u0026 authorization. \n\n# Requirements\n\niOS 8.0+ / Xcode 8.0+ (Swift 3)\n\n# Set up\n\nStormpath's iOS SDK allows developers utilizing Stormpath to quickly integrate authentication and token management into their apps. \n\nWe're constantly iterating and improving the SDK, so please don't hesitate to send us your feedback! You can reach us via support@stormpath.com, or on the issue tracker for feature requests. \n\n# Installation\n\n## CocoaPods\n\nStormpath is available through [CocoaPods](https://cocoapods.org/). Add this line to your `Podfile` to begin:\n\n```ruby\npod 'Stormpath', '~\u003e 3.0'\n```\n\n## Carthage\n\nTo use Stormpath with [Carthage](https://github.com/Carthage/Carthage), specify it in your `Cartfile`:\n\n```ogdl\ngithub \"stormpath/stormpath-sdk-ios\" ~\u003e 3.0\n```\n\n# Usage\n\nTo see the SDK in action, you can try downloading the [Stormpath iOS Example](https://github.com/stormpath/stormpath-ios-example) project. We've built the same app twice, once in Objective-C and another time in Swift so you can see how to use the SDK. \n\n## Importing the framework\n\nFor Swift projects:\n\n```Swift\nimport Stormpath\n```\n\nFor Objective-C projects: \n\n```Objective-C\n#import \"Stormpath-Swift.h\"\n```\n\n## Configuring Stormpath\n\nThe iOS SDK (v3) leverages the [Stormpath Client API](https://docs.stormpath.com/client-api/product-guide/latest/index.html) for its authentication needs. You'll need to sign into the [Stormpath Admin Console](https://api.stormpath.com/) to get your Client API details. Go into your Application \u003e Policies \u003e Client API, and ensure that it's enabled. Copy your Client API URL, and set it in your Xcode project: \n\nSwift:\n\n```Swift\nStormpath.sharedSession.configuration.APIURL = URL(string: \"https://edjiang.apps.stormpath.io\")!\n```\n\nObjective-C:\n\n```Objective-C\n[[SPHStormpath sharedSession] configuration].APIURL = [[NSURL alloc] initWithString:@\"https://edjiang.apps.stormpath.io\"];\n```\n\n## User registration\n\nIn order to register a user, instantiate a `RegistrationForm` object. Stormpath requires an `email` and `password` to register.\n\n```Swift\nlet newUser = RegistrationForm(email: \"user@example.com\", password: \"ExamplePassword\")\n```\n\nThen, just invoke the register method on `Stormpath` class:\n\n```Swift\nStormpath.sharedSession.register(account: newUser) { (account, error) -\u003e Void in\n    guard let account = account where error == nil else {\n        //The account registration failed\n        return\n    }\n    // Do something with the returned account object, such as save its `href` if needed. \n    // Registering a user will not automatically log them in. \n}\n```\n\n*Note: Stormpath callbacks always happen on the main thread, so you can make UI changes directly in the callback.*\n\n## Logging in\n\nTo log in, collect the email (or username) and password from the user, and then pass them to the login method:\n\n```Swift\nStormpath.sharedSession.login(username: \"user@example.com\", password: \"ExamplePassword\") { success, error in\n    guard error == nil else {\n        // We could not authenticate the user with the given credentials. Handle the error. \n        return\n    }\n    // The user is now logged in, and you can use the Stormpath access token to make API requests!\n}\n```\n\n## Logging in with Social Providers\n\nStormpath also supports logging in with a variety of social providers Facebook, Google, LinkedIn, GitHub, and more. There are two flows for enabling this:\n\n1. Let Stormpath handle the social login.\n2. Use the social provider's iOS SDK to get an access token, and pass it to Stormpath to log in.\n\nWe've made it extremely easy to set up social login without using the social provider SDKs, but if you need to use their SDKs for more features besides logging in, you should use flow #2 (and skip directly to [Using a social provider SDK](#using-a-social-provider-sdk)). \n\n### Configure Your Social Directory in Stormpath\n\nTo set up your social directory, read more about [social login in the Stormpath Client API Guide](https://docs.stormpath.com/client-api/product-guide/latest/social_login.html#before-you-start).\n\n### Setting up your Xcode project\n\nIn your Xcode project, you'll need to create a URL Scheme so that the login process can call back to your app. Go to the project's info tab. Under \"URL Types\", add a new entry, and in the URL schemes form field, type in your Client API's DNS label, but reversed. For instance, if your Client API DNS Label is `edjiang.apps.stormpath.io`, type in `io.stormpath.apps.edjiang`. \n\nIn the [Stormpath Admin Console](https://api.stormpath.com)'s Application settings, add that URL as an \"authorized callback URL\", appending `://stormpathCallback`. Following my earlier example, I would use `io.stormpath.apps.edjiang`. \n\nAlso, add the following methods to your `AppDelegate` in your Xcode project:\n\n```Swift\n// iOS 9+ link handler\nfunc application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -\u003e Bool {\n    return Stormpath.sharedSession.application(app, open: url, options: options)\n}\n\n// iOS 8 and below link handler. Needed if you want to support older iOS\nfunc application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -\u003e Bool {\n    return Stormpath.sharedSession.application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)\n}\n```\n\n### Initiating Social Login\n\nNow, you can initiate the login screen by calling: \n\n```Swift\nStormpath.sharedSession.login(provider: .facebook) { (success, error) -\u003e Void in\n    // This callback is the same as the regular Stormpath.login callback. \n    // If the user cancels the login, the login was never started, and\n    // this callback will not be called.\n}\n```\n\n### Using a Social Provider SDK\n\nIf you're using the [Facebook SDK](https://developers.facebook.com/docs/facebook-login/ios) or [Google SDK](https://developers.google.com/identity/sign-in/ios/) for your app, follow their setup instructions instead. Once you successfully sign in with their SDK, utilize the following methods to send your access token to Stormpath, and log in your user: \n\n```Swift\nStormpath.sharedSession.login(provider: .facebook, accessToken: FBSDKAccessToken.currentAccessToken().tokenString) { (success, error) -\u003e Void in\n\t// Same callback as above\n}\n\nStormpath.sharedSession.login(provider: .google, accessToken: GIDSignIn.sharedInstance().currentUser.authentication.accessToken) { (success, error) -\u003e Void in\n\t// Same callback as above\n}\n```\n\n## Using the Access Token\n\nYou can utilize the access token to access any of your API endpoints that require authentication. It's stored as a property on the Stormpath object as `Stormpath.sharedSession.accessToken`. If you need to refresh it, use `Stormpath.sharedSession.refreshAccessToken()`. Depending on the networking library you're using, here's how you'd use the access token:\n\n### NSURLSession\n\n```Swift\nvar request = URLRequest(URL: url)\nrequest.setValue(\"Bearer \" + accessToken ?? \"\", forHTTPHeaderField: \"Authorization\")\n```\n\n### Alamofire\n\n```Swift\nlet headers = [\"Authorization\": \"Bearer \" + accessToken ?? \"\"]\nAlamofire.request(url, method: .get, headers: headers)\n```\n\n*Note: As of the iOS 9 SDK, Apple has enabled App Transport Security by default. If you're developing against an `http` endpoint, you'll need to disable it. For production, you should always be using `https` for your API endpoints.*\n\n## Account data\n\nStormpath's framework integrations provide a default endpoint for retrieving profile information. Fetch the account data by using me:\n\n```Swift\nStormpath.sharedSession.me { account, error in\n\tguard let account = account where error == nil else {\n\t    // We might not be logged in, the API is misconfigured, the API is down, etc\n\t    return\n\t}\n\t// Success! We have the account object.\n}\n```\n\n## Logout\n\nLogging out is simple. This will delete the access token and refresh token from the user's device, and make an API request to delete from the server. \n\n```Swift\nStormpath.sharedSession.logout()\n```\n\n## Password reset\n\nTo reset a user's password, you'll need to collect their email first. Then simply pass that email to the `resetPassword` function like so:\n\n```Swift\nStormpath.sharedSession.resetPassword(email: \"user@example.com\") { success, error in\n    guard error == nil else {\n    \t// A network or API problem occurred. \n        return\n    }\n    // We succeeded in making the API request. \n}\n```\n\n## Error handling\n\nWhen using Stormpath, you can encounter errors for several reasons: \n\n1. Network errors - the network request failed for some reason. \n2. User errors - errors because of user input, ex: \"invalid username or password\".\n3. API errors - the API is misconfigured, or returning an unrecognized response. \n\nIf there's a network error, Stormpath will return the `NSError` associated with `NSURLSession` to your code. Otherwise, Stormpath will return `StormpathError`, a `NSError` subclass. \n\nFor user errors, `StormpathError` will have the HTTP error code of the API response (usually 400), and `localizedDescription` set to a user-readable error message which is safe to display to the user. \n\nIn special cases, StormpathError will have code 0 or 1. These are developer errors that should not be displayed to the user. 0 stands for \"Stormpath SDK Error\", and most likely indicates a bug with the Stormpath SDK that should be reported to us. 1 stands for \"API Response Error\", and means that the API responded with something unexpected. This most likely means that you have your backend integration misconfigured. \n\n## Configuring Stormpath with Info.plist\n\n`StormpathConfiguration` can be used to point Stormpath to a specific API URL. While you can modify the object directly, you can also put your configuration in Info.plist. To add the Stormpath configuration, right click on Info.plist, and click \"open as source code\". Before the last `\u003c/plist\u003e` tag, paste: \n\n```xml\n\u003ckey\u003eStormpath\u003c/key\u003e\n\u003cdict\u003e\n\t\u003ckey\u003eAPIURL\u003c/key\u003e\n\t\u003cstring\u003ehttp://localhost:3000\u003c/string\u003e\n\u003c/dict\u003e\n```\n\nYou can modify any of these values, and `StormpathConfiguration` will load these on first initialization. \n\n## Handling Multiple Sessions\n\nStormpath can be used to store multiple user accounts, even against multiple API servers using Stormpath. This is useful if you're making a multi-tenant application that allows the user to be logged in under different accounts at the same time. \n\nTo use this feature, instead of using `Stormpath.sharedSession`, initialize Stormpath with a custom identifier:\n\n```Swift\nStormpath(identifier: \"newSession\")\n```\n\nThis will create an instance of Stormpath with the default configuration (shared with the rest of the app) that will store `accessTokens` and `refreshTokens` in its own partition in the iOS Keychain. \n\nThis identifier can be used in your app to identify a user session contained in Stormpath, and properly restore it in between app opens. \n\n*Note: the identifier for `Stormpath.sharedSession` is \"default\", so do not use this as an identifier for another instance of Stormpath.*\n\n# License\n\nThis project is open-source via [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstormpath%2Fstormpath-sdk-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstormpath%2Fstormpath-sdk-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstormpath%2Fstormpath-sdk-ios/lists"}