         requestToken(.AuthorizationCode(code), completion: completion)
     }
     
-    internal func requestToken(grantType: GrantType, completion: Result<Token, Error> -> Void) {
+    func shouldHandleURL(URL: NSURL, options: [String: AnyObject]) -> Bool {
+        guard isLegitSourceApplication(options) else {
+            return false
+        }
+        
+        guard state == URL.queries["state"] else {
+            return false
+        }
+        
+        return matchingURLs(URL, redirectURL) ? true : false
+    }
+    
+    func isLegitSourceApplication(options: [String: AnyObject]) -> Bool {
+        guard let sourceApplication = options["UIApplicationOpenURLOptionsSourceApplicationKey"] as? String else {
+            return false
+        }
+        
+        return ["com.apple.mobilesafari", "com.apple.SafariViewService"].contains(sourceApplication)
+    }
+    
+    func matchingURLs(a: NSURL, _ b: NSURL) -> Bool {
+        return (a.scheme, a.host, a.path) == (b.scheme, b.host, b.path)
+    }
+}
+
+// MARK: - Request Token
+
+private extension Provider {
+    func requestToken(grantType: GrantType, completion: Result<Token, Error> -> Void) {
         var params = [
             "client_id": clientID,
             "client_secret": clientSecret,

    }
}

// MARK: - Token Response Type

extension Provider {
    func handleURLForTokenResponseType(URL: NSURL, completion: Result<Token, Error> -> Void) {
        let result: Result<Token, Error>
        

    }
}

// MARK: - Close Browser Window

@available(iOS 9.0, *)
extension Provider: SFSafariViewControllerDelegate {
