OAuth2Authorizer
open class OAuth2Authorizer : OAuth2AuthorizerUI
The authorizer to use when on the macOS platform.
You can subclass this class and override presentableAuthorizeViewController(url:) and/or windowController(controller:config:) to further
customize appearance.
-
The OAuth2 instance this authorizer belongs to.
Declaration
Swift
public unowned let oauth2: OAuth2Base -
Stores the default
NSWindowControllercreated to contain the web view controller.Declaration
Swift
var windowController: NSWindowController? -
Designated initializer.
Declaration
Swift
public init(oauth2: OAuth2Base)Parameters
oauth2The OAuth2 instance for which to present an authorization UI
-
Uses
NSWorkspaceto open the authorize URL in the OS browser.Throws
UnableToOpenAuthorizeURL on failureDeclaration
Swift
public func openAuthorizeURLInBrowser(_ url: URL) throwsParameters
urlThe authorize URL to open
-
Tries to use the given context, which on OS X should be a NSWindow, to present the authorization screen. In this case will forward to
authorizeEmbedded(from:with:at:), if the context is empty will create a new NSWindow by callingauthorizeInNewWindow(with:at:).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
-
Presents a modal sheet from the given window.
Declaration
Swift
@available(macOS 10.10, *) @discardableResult public func authorizeEmbedded(from window: NSWindow, at url: URL) throws -> NSWindowParameters
fromThe window from which to present the sheet
atThe authorize URL to open
Return Value
The sheet that is being queued for presentation
-
Creates a new window, containing our
OAuth2WebViewController, and centers it on the screen.Declaration
Swift
@available(macOS 10.10, *) @discardableResult open func authorizeInNewWindow(at url: URL) throws -> NSWindowControllerParameters
atThe authorize URL to open
Return Value
The window that is being shown on screen
-
Instantiates and configures an
OAuth2WebViewController, ready to be used in a window.Declaration
Swift
@available(macOS 10.10, *) open func presentableAuthorizeViewController(at url: URL) throws -> OAuth2WebViewControllerParameters
atThe authorize URL to open
Return Value
A web view controller that you can present to the user for login
-
Prepares a window controller with the given web view controller as content.
Declaration
Swift
@available(macOS 10.10, *) open func windowController(forViewController controller: OAuth2WebViewController, with config: OAuth2AuthConfig) -> NSWindowControllerParameters
forViewControllerThe web view controller to use as content
withThe auth config to use
Return Value
A window controller, ready to be presented
View on GitHub
Install in Dash
OAuth2Authorizer Class Reference