Latest 2.0.0
License BSD
Platforms osx 10.11, requires ARC
Authors , ,

Build Status
CocoaPods Compatible
Carthage Compatible
GitHub license

DuoAPISwift is an API client to call Duo API methods with Swift.

Duo Auth API

The Duo Auth API provides a low-level API for adding strong two-factor authentication to applications that cannot directly display rich web content.



To install DuoAPISwift with CocoaPods, add the following line to your Podfile.

pod 'DuoAPISwift', '~> 2.0'

Then run pod install to add DuoAPISwift to your project.


To install DuoAPISwift with Carthage, add the following to your Cartfile.

github "duosecurity/duo_api_swift" ~> 2.0

Then run carthage update to build the framework. When finished, drag DuoAPISwift.framework to your Xcode project.


Creating the Auth Object

import DuoAPISwift

let auth = Auth(
    ikey: "<IKEY>",
    skey: "<SKEY (Keep this secret!)>",
    host: "")

Verify that Duo Is Up and Running{response in

Verify IKEY, SKEY, and Signature

auth.check({response in

Retrieve Stored Logo

auth.logo({ response in
    if let data = response as? NSData {
        if let image = NSImage(data: data as Data) {
            self.logoImageView.image = image

Send a Duo Push Authentication Request

          username: "<USERNAME>",
          device: "auto",
          completion: { response in
    var allowed = false
    if let r = response["response"] as? [String : Any],
            let result = r["result"] as? String {
        if result == "allow" {
            allowed = true
    if allowed {
        print("Success. Logging you in...")
    } else {
        print("Access denied.")

Latest podspec

    "name": "DuoAPISwift",
    "version": "2.0.0",
    "summary": "Duo Security API client for Swift.",
    "homepage": "",
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    "authors": {
        "James Barclay": "[email protected]",
        "Mark Lee": "[email protected]",
        "Mike Brown": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "osx": "10.11"
    "requires_arc": true,
    "source": {
        "git": "",
        "tag": "2.0.0",
        "submodules": true
    "source_files": "DuoAPISwift/**/*.{h,swift}",
    "resources": [
        "DuoAPISwift/Trusted\ CA\ Certificates/*.der"
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This