Home

Awesome

SwiftOAuth2

A Swift implementation of OAuth2 for iOS.

#Setup

CROAuth2Client relies on Alamofire, from the excellent Mattt

It is added as a submodule in this repository.

To use correctly CROAuth2Client, please add it as a submodule:

git submodule init 
git submodule add git@github.com:crousselle/SwiftOAuth2.git 
// --recursive to get Alamofire
git submodule update --init --recursive

Please follow instructions at https://github.com/Alamofire/Alamofire to set up Alamofire in your project.

#Usage

You first need to create a CROAuth2Client object via the following method:

// From a UIViewController (used to present the authentication webview if necessary)
CROAuth2Client.clientWithPresentingController(self)

Then simply query the access token:

self.client!.retrieveAuthToken({ (authToken) -> Void in
       
        if let authToken = authToken {
            println("Received access token " + authToken)
        }
       
    })

The client will automatically return a valid token from the authentication server, or the keychain.

#Creator Clément Rousselle @clemrousselle