OAuth2Authorizer
open class OAuth2Authorizer: OAuth2AuthorizerUI
This authorizer takes care of iOS-specific tasks when showing the authorization UI.
You can subclass this class and override willPresent(viewController:naviController:) in order to further customize presentation of the UI.
-
The OAuth2 instance this authorizer belongs to.
Declaration
Swift
public unowned let oauth2: OAuth2Base -
Undocumented
Declaration
Swift
open class OAuth2Authorizer: OAuth2AuthorizerUI
-
Uses
UIApplicationto open the authorize URL in iOS’s browser.Throws
UnableToOpenAuthorizeURL on failureDeclaration
Swift
public func openAuthorizeURLInBrowser(_ url: URL) throwsParameters
urlThe authorize URL to open
-
Tries to use the current auth config context, which on iOS should be a UIViewController, to present the authorization screen.
Throws
Can throw OAuth2Error if the method is unable to show the authorize screenDeclaration
Swift
public func authorizeEmbedded(with config: OAuth2AuthConfig, at url: URL) throwsParameters
withThe configuration to be used; usually uses the instance’s
authConfigatThe authorize URL to open
-
Called with the view- and (possibly) navigation-controller that is about to be presented. Useful for subclasses, default implementation does nothing.
Declaration
Swift
open func willPresent(viewController: UIViewController, in naviController: UINavigationController?)Parameters
viewControllerThe Safari- or web view controller that will be presented
naviControllerThe navigation controller embedding the view controller, if any
-
Presents a Safari view controller from the supplied view controller, loading the authorize URL.
The mechanism works just like when you’re using Safari itself to log the user in, hence you need to implement
application(application:openURL:sourceApplication:annotation:)in your application delegate.This method does NOT dismiss the view controller automatically, you probably want to do this in the callback. Simply call this method first, then call
dismissViewController()on the returned web view controller instance in that closure. Or useauthorizeEmbedded(with:at:)which does all this automatically.Declaration
Swift
public func authorizeSafariEmbedded(from controller: UIViewController, at url: URL) throws -> SFSafariViewControllerParameters
fromThe view controller to use for presentation
atThe authorize URL to open
Return Value
SFSafariViewController, being already presented automatically
-
Presents a web view controller, contained in a UINavigationController, on the supplied view controller and loads the authorize URL.
Automatically intercepts the redirect URL and performs the token exchange. It does NOT however dismiss the web view controller automatically, you probably want to do this in the callback. Simply call this method first, then assign that closure in which you call
dismissViewController()on the returned web view controller instance.Declaration
Swift
public func authorizeEmbedded(from controller: UIViewController, at url: URL) throws -> OAuth2WebViewControllerParameters
fromThe view controller to use for presentation
atThe authorize URL to open
Return Value
OAuth2WebViewController, embedded in a UINavigationController being presented automatically
View on GitHub
Install in Dash
OAuth2Authorizer Class Reference