{"id":810,"url":"https://github.com/OAuthSwift/OAuthSwift","last_synced_at":"2025-08-06T14:31:14.176Z","repository":{"id":40633254,"uuid":"21315049","full_name":"OAuthSwift/OAuthSwift","owner":"OAuthSwift","description":"Swift based OAuth library for iOS","archived":false,"fork":false,"pushed_at":"2024-05-15T16:46:29.000Z","size":4025,"stargazers_count":3316,"open_issues_count":55,"forks_count":599,"subscribers_count":90,"default_branch":"master","last_synced_at":"2025-07-30T16:39:19.588Z","etag":null,"topics":["oauth","oauth-client","oauth1","oauth2","oauth2-authentication","oauth2-client","oauthswift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OAuthSwift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["phimage","dongri"]}},"created_at":"2014-06-29T02:27:16.000Z","updated_at":"2025-07-27T19:20:02.000Z","dependencies_parsed_at":"2024-01-02T20:50:40.266Z","dependency_job_id":"d199b87b-84a2-4948-8522-92bb6003b4bb","html_url":"https://github.com/OAuthSwift/OAuthSwift","commit_stats":{"total_commits":621,"total_committers":136,"mean_commits":"4.5661764705882355","dds":0.8341384863123994,"last_synced_commit":"a04f7b78e3160b7ee1c46720d8c51c6e97dda2cf"},"previous_names":["dongri/oauthswift"],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/OAuthSwift/OAuthSwift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OAuthSwift%2FOAuthSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OAuthSwift%2FOAuthSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OAuthSwift%2FOAuthSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OAuthSwift%2FOAuthSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OAuthSwift","download_url":"https://codeload.github.com/OAuthSwift/OAuthSwift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OAuthSwift%2FOAuthSwift/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268108105,"owners_count":24197609,"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-07-31T02:00:08.723Z","response_time":66,"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":["oauth","oauth-client","oauth1","oauth2","oauth2-authentication","oauth2-client","oauthswift"],"created_at":"2024-01-05T20:15:31.846Z","updated_at":"2025-08-06T14:31:13.644Z","avatar_url":"https://github.com/OAuthSwift.png","language":"Swift","funding_links":["https://github.com/sponsors/phimage","https://github.com/sponsors/dongri"],"categories":["Authentication","Libs","Swift","Network [🔝](#readme)"],"sub_categories":["Network","Other free courses","Getting Started"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Assets/OAuthSwift-icon.png?raw=true\" alt=\"OAuthSwift\"/\u003e\n\u003c/p\u003e\n\n# OAuthSwift\n\nSwift based OAuth library for iOS and macOS.\n\n## Support OAuth1.0, OAuth2.0\n\nTwitter, Flickr, Github, Instagram, Foursquare, Fitbit, Withings, Linkedin, Dropbox, Dribbble, Salesforce, BitBucket, GoogleDrive, Smugmug, Intuit, Zaim, Tumblr, Slack, Uber, Gitter, Facebook, Spotify, Typetalk, SoundCloud, Twitch, Reddit, etc\n\n## Installation\n\nOAuthSwift is packaged as a Swift framework. Currently this is the simplest way to add it to your app:\n\n* Drag OAuthSwift.xcodeproj to your project in the Project Navigator.\n* Select your project and then your app target. Open the Build Phases panel.\n* Expand the Target Dependencies group, and add OAuthSwift framework.\n* import OAuthSwift whenever you want to use OAuthSwift.\n\n### Support Carthage\n\n* Install Carthage (https://github.com/Carthage/Carthage)\n* Create `Cartfile` file\n\n```text\ngithub \"OAuthSwift/OAuthSwift\" ~\u003e 2.2.0\n```\n\n* Run `carthage update`.\n* On your application targets’ “General” settings tab, in the “Embedded Binaries”\nsection, drag and drop OAuthSwift.framework from the Carthage/Build/iOS folder on disk.\n\n### Support CocoaPods\n\n* Podfile\n\n```ruby\nplatform :ios, '10.0'\nuse_frameworks!\n\npod 'OAuthSwift', '~\u003e 2.2.0'\n```\n\n### Swift Package Manager Support\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyApp\",\n    dependencies: [\n        .package(name: \"OAuthSwift\",\n            url: \"https://github.com/OAuthSwift/OAuthSwift.git\",\n            .upToNextMajor(from: \"2.2.0\"))\n    ]\n)\n```\n\n### Old versions\n\n#### Swift 3\n\nUse the `swift3` branch, or the tag `1.1.2` on main branch\n\n#### Swift 4\n\nUse the tag `1.2.0` on main branch\n\n#### Objective-C\n\nUse the tag `1.4.1` on main branch\n\n## How to\n\n### Setting URL Schemes\n\nIn info tab of your target\n![Image](Assets/URLSchemes.png \"Image\")\nReplace oauth-swift by your application name\n\n### Handle URL in AppDelegate\n\n- On iOS implement `UIApplicationDelegate` method\n\n```swift\nfunc application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey  : Any] = [:]) -\u003e Bool {\n  if url.host == \"oauth-callback\" {\n    OAuthSwift.handle(url: url)\n  }\n  return true\n}\n```\n\n- On iOS 13, UIKit will notify `UISceneDelegate` instead of `UIApplicationDelegate`.\n- Implement `UISceneDelegate` method\n\n```swift\nfunc scene(_ scene: UIScene, openURLContexts URLContexts: Set\u003cUIOpenURLContext\u003e) {\n        guard let url = URLContexts.first?.url else {\n            return\n        }\n        if url.host == \"oauth-callback\" {\n            OAuthSwift.handle(url: url)\n        }\n}\n```\n\n:warning: Any other application may try to open a URL with your url scheme. So you can check the source application, for instance for safari controller :\n\n```swift\nif options[.sourceApplication] as? String == \"com.apple.SafariViewService\" {\n```\n\n- On macOS you must register a handler on `NSAppleEventManager` for event type `kAEGetURL` (see demo code)\n\n```swift\nfunc applicationDidFinishLaunching(_ aNotification: NSNotification) {\n    NSAppleEventManager.shared().setEventHandler(self, andSelector:#selector(AppDelegate.handleGetURL(event:withReplyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))\n}\nfunc handleGetURL(event: NSAppleEventDescriptor!, withReplyEvent: NSAppleEventDescriptor!) {\n    if let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue, let url = URL(string: urlString) {\n        OAuthSwift.handle(url: url)\n    }\n}\n```\n\n### Authorize with OAuth1.0\n\n```swift\n// create an instance and retain it\noauthswift = OAuth1Swift(\n    consumerKey:    \"********\",\n    consumerSecret: \"********\",\n    requestTokenUrl: \"https://api.twitter.com/oauth/request_token\",\n    authorizeUrl:    \"https://api.twitter.com/oauth/authorize\",\n    accessTokenUrl:  \"https://api.twitter.com/oauth/access_token\"\n)\n// authorize\nlet handle = oauthswift.authorize(\n    withCallbackURL: \"oauth-swift://oauth-callback/twitter\") { result in\n    switch result {\n    case .success(let (credential, response, parameters)):\n      print(credential.oauthToken)\n      print(credential.oauthTokenSecret)\n      print(parameters[\"user_id\"])\n      // Do your request\n    case .failure(let error):\n      print(error.localizedDescription)\n    }             \n}\n```\n\n### OAuth1 without authorization\n\nNo urls to specify here\n\n```swift\n// create an instance and retain it\noauthswift = OAuth1Swift(\n    consumerKey:    \"********\",\n    consumerSecret: \"********\"\n)\n// do your HTTP request without authorize\noauthswift.client.get(\"https://api.example.com/foo/bar\") { result in\n    switch result {\n    case .success(let response):\n        //....\n    case .failure(let error):\n        //...\n    }\n}\n```\n\n### Authorize with OAuth2.0\n\n```swift\n// create an instance and retain it\noauthswift = OAuth2Swift(\n    consumerKey:    \"********\",\n    consumerSecret: \"********\",\n    authorizeUrl:   \"https://api.instagram.com/oauth/authorize\",\n    responseType:   \"token\"\n)\nlet handle = oauthswift.authorize(\n    withCallbackURL: \"oauth-swift://oauth-callback/instagram\",\n    scope: \"likes+comments\", state:\"INSTAGRAM\") { result in\n    switch result {\n    case .success(let (credential, response, parameters)):\n      print(credential.oauthToken)\n      // Do your request\n    case .failure(let error):\n      print(error.localizedDescription)\n    }\n}\n```\n\n### Authorize with OAuth2.0 and proof key flow (PKCE)\n\n```swift\n// create an instance and retain it\noauthswift = OAuth2Swift(\n    consumerKey:    \"********\",\n    consumerSecret: \"********\",\n    authorizeUrl: \"https://server.com/oauth/authorize\",\n    responseType: \"code\"\n)\noauthswift.accessTokenBasicAuthentification = true\n\nguard let codeVerifier = generateCodeVerifier() else {return}\nguard let codeChallenge = generateCodeChallenge(codeVerifier: codeVerifier) else {return}\n\nlet handle = oauthswift.authorize(\n    withCallbackURL: \"myApp://callback/\",\n    scope: \"requestedScope\", \n    state:\"State01\",\n    codeChallenge: codeChallenge,\n    codeChallengeMethod: \"S256\",\n    codeVerifier: codeVerifier) { result in\n    switch result {\n    case .success(let (credential, response, parameters)):\n      print(credential.oauthToken)\n      // Do your request\n    case .failure(let error):\n      print(error.localizedDescription)\n    }\n}\n```\n\nSee demo for more examples\n\n### Handle authorize URL\nThe authorize URL allows the user to connect to a provider and give access to your application.\n\nBy default this URL is opened into the external web browser (ie. safari), but apple does not allow it for app-store iOS applications.\n\nTo change this behavior you must set an `OAuthSwiftURLHandlerType`, simple protocol to handle an `URL`\n\n```swift\noauthswift.authorizeURLHandler = ..\n```\n\nFor instance you can embed a web view into your application by providing a controller that displays a web view (`UIWebView`, `WKWebView`).\nThen this controller must implement `OAuthSwiftURLHandlerType` to load the URL into the web view\n\n```swift\nfunc handle(_ url: NSURL) {\n  let req = URLRequest(URL: targetURL)\n  self.webView.loadRequest(req)\n  ...\n```\n\nand present the view (`present(viewController`, `performSegue(withIdentifier: `, ...)\n*You can extend `OAuthWebViewController` for a default implementation of view presentation and dismiss*\n\n#### Use the SFSafariViewController (iOS9)\n\nA default implementation of `OAuthSwiftURLHandlerType` is provided using the `SFSafariViewController`, with automatic view dismiss.\n\n```swift\noauthswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift)\n```\n\nOf course you can create your own class or customize the controller by setting the variable `SafariURLHandler#factory`.\n\n### Make signed request\n\nJust call HTTP functions of `oauthswift.client`\n\n```swift\noauthswift.client.get(\"https://api.linkedin.com/v1/people/~\") { result in\n    switch result {\n    case .success(let response):\n        let dataString = response.string\n        print(dataString)\n    case .failure(let error):\n        print(error)\n    }\n}\n// same with request method\noauthswift.client.request(\"https://api.linkedin.com/v1/people/~\", .GET,\n      parameters: [:], headers: [:],\n      completionHandler: { ...\n```\n\nSee more examples in the demo application: [ViewController.swift](/Demo/Common/ViewController.swift)\n\n## OAuth provider pages\n\n* [Twitter](https://dev.twitter.com/oauth)  \n* [Flickr](https://www.flickr.com/services/api/auth.oauth.html)  \n* [Github](https://developer.github.com/v3/oauth/)  \n* [Instagram](https://developers.facebook.com/docs/instagram-basic-display-api/guides/getting-access-tokens-and-permissions)  \n* [Foursquare](https://developer.foursquare.com/overview/auth)  \n* [Fitbit](https://dev.fitbit.com/build/reference/web-api/oauth2/)  \n* [Withings](http://oauth.withings.com/api)  \n* [LinkedIn](https://docs.microsoft.com/en-us/linkedin/shared/authentication/authentication)  \n* [Dropbox](https://www.dropbox.com/developers/documentation/http/documentation)  \n* [Dribbble](https://developer.dribbble.com/v2/#authentication)\n* [Salesforce](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/)\n* [BitBucket](https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html)\n* [GoogleDrive](https://developers.google.com/drive/v2/reference/)\n* [Smugmug](https://smugmug.atlassian.net/wiki/display/API/OAuth)\n* [Intuit](https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization)\n* [Zaim](https://dev.zaim.net/home/api/authorize)\n* [Tumblr](https://www.tumblr.com/docs/en/api/v2#auth)\n* [Slack](https://api.slack.com/docs/oauth)\n* [Uber](https://developer.uber.com/docs/ride-requests/guides/authentication/introduction#oauth-20)\n* [Gitter](https://developer.gitter.im/docs/authentication)\n* [Facebook](https://developers.facebook.com/docs/facebook-login)\n* [Spotify](https://developer.spotify.com/web-api/authorization-guide/)\n* [Trello](https://developers.trello.com/authorize)\n* [Buffer](https://buffer.com/developers/api/oauth)\n* [Goodreads](https://www.goodreads.com/api/documentation#oauth)\n* [Typetalk](http://developer.nulab-inc.com/docs/typetalk/auth)\n* [SoundCloud](https://developers.soundcloud.com/docs/api/guide#authentication)\n* [Doper](https://doper.io/developer/oauth)\n* [NounProject](http://api.thenounproject.com/getting_started.html#authentication)\n* [Reddit](https://github.com/reddit-archive/reddit/wiki/oauth2)\n\n## Images\n\n![Image](Assets/Services.png \"Image\")\n![Image](Assets/TwitterOAuth.png \"Image\")\n![Image](Assets/TwitterOAuthTokens.png \"Image\")\n\n## Contributing\n\nSee [CONTRIBUTING.md](.github/CONTRIBUTING.md)\n\n[Add a new service in demo app](https://github.com/OAuthSwift/OAuthSwift/wiki/Demo-application#add-a-new-service-in-demo-app)\n\n## Integration\n\nOAuthSwift could be used with others frameworks\n\nYou can sign [Alamofire](https://github.com/Alamofire/Alamofire) request with [OAuthSwiftAlamofire](https://github.com/OAuthSwift/OAuthSwiftAlamofire)\n\nTo achieve great asynchronous code you can use one of these integration frameworks\n\n- [OAuthSwiftFutures](https://github.com/OAuthSwift/OAuthSwiftFutures) - [BrightFutures](https://github.com/Thomvis/BrightFutures)\n- [OAuthRxSwift](https://github.com/OAuthSwift/OAuthRxSwift) - [RxSwift](https://github.com/ReactiveX/RxSwift)\n- [OAuthReactiveSwift](https://github.com/OAuthSwift/OAuthReactiveSwift) - [ReactiveSwift](https://github.com/ReactiveCocoa/ReactiveSwift)\n\n## License\n\nOAuthSwift is available under the MIT license. See the LICENSE file for more info.\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n            )](http://mit-license.org) [![Platform](https://img.shields.io/badge/platform-iOS_OSX_TVOS-lightgrey.svg?style=flat\n             )](https://developer.apple.com/resources/) [![Language](https://img.shields.io/badge/language-swift-orange.svg?style=flat\n             )](https://developer.apple.com/swift) [![Cocoapod](https://img.shields.io/cocoapods/v/OAuthSwift.svg?style=flat)](http://cocoadocs.org/docsets/OAuthSwift/)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.org/OAuthSwift/OAuthSwift.svg?branch=master)](https://travis-ci.org/OAuthSwift/OAuthSwift)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOAuthSwift%2FOAuthSwift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOAuthSwift%2FOAuthSwift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOAuthSwift%2FOAuthSwift/lists"}