Skip to content

dani-mp/Paparajote

 
 

Repository files navigation

header

CI Status codecov Dependency Status

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Paparajote is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Paparajote"

Use

Providers

In order to use Paparajote you have to make sure the provider is supported. You can check it in the list of supported providers. If it's not supported, you can easily give support to a new provider conforming the protocol:

public typealias Authorization = () -> NSURL
public typealias Authentication = NSURL -> NSURLRequest?
public typealias SessionAdapter = (NSData, NSURLResponse) -> OAuth2Session?

public protocol OAuth2Provider {
    var authorization: Authorization { get }
    var authentication: Authentication { get }
    var sessionAdapter: SessionAdapter { get }
}
  • Authorization: Returns the URL that triggers the OAuth2 flow.
  • Authentication: Returns an authentication request if the url contains an authentication token.
  • SessionAdapter: Extracts the session from the authentication response data.

Using UIWebView (iOS only)

If you're using UIWebView from UIKit you can trigger the OAuth2 with a few simple steps:

  1. Create an instance of OAuth2WebviewDelegate passing the provider, the webview, and a completion closure that will be executed once the authentication completes.
  2. Keep a reference to that delegate from your ViewController.

Using WKWebView (iOS and macOS)

If you're using WKWebView from WKWebKit you can trigger the OAuth2 with a few simple steps:

  1. Create an instance of OAuth2WKNavigationDelegate passing the provider, the webview, and a completion closure that will be executed once the authentication completes.
  2. Keep a reference to that delegate from your ViewController.

About

This project is funded and maintained by Caramba. We 💛 open source software!

Check out our other open source projects, read our blog or say 👋 on twitter @carambalabs.

Contribute

Contributions are welcome 🤘 We encourage developers like you to help us improve the projects we've shared with the community. Please see the Contributing Guide and the Code of Conduct.

License

Paparajote is available under the MIT license. See the LICENSE file for more info.

About

Oauth2 handler written in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 80.3%
  • Ruby 19.7%