     public func handleURL(URL: NSURL, options: [String: AnyObject]) {
         guard shouldHandleURL(URL, options: options) else { return }
         
+        safariVC?.dismissViewControllerAnimated(true, completion: nil)
         NotificationCenter.removeObserver(self, name: UIApplicationDidBecomeActiveNotification)
         
         guard let code = URL.query("code") else {

@available(iOS 9.0, *)
extension Provider: SFSafariViewControllerDelegate {
    public func safariViewControllerDidFinish(controller: SFSafariViewController) {
        failure(.Cancel)
    }
}

    
    private func success(token: Token) {
        Queue.main { [weak self] in
            self?.completion?(.Success(token))
        }
    }
    
    private func failure(error: Error) {
        Queue.main { [weak self] in
            self?.completion?(.Failure(error))
        }
    }
    
