         return matchingURLs(URL, redirectURL) ? true : false
     }
     
-    func isLegitSourceApplication(options: [String: AnyObject]) -> Bool {
-        guard let sourceApplication = options["UIApplicationOpenURLOptionsSourceApplicationKey"] as? String else {
-            return false
-        }
+    func isLegitSourceApplication(sourceApplication: String?) -> Bool {
+        guard let sourceApplication = sourceApplication else { return false }
         
         return ["com.apple.mobilesafari", "com.apple.SafariViewService"].contains(sourceApplication)
     }

     - parameter URL:     The incoming URL to handle.
     - parameter options: A dictionary of launch options.
     */
    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)

        requestToken(.AuthorizationCode(code), completion: completion)
    }
    
    func shouldHandleURL(URL: NSURL, sourceApplication: String?) -> Bool {
        guard isLegitSourceApplication(sourceApplication) else { return false }
        
        guard state == URL.queries["state"] else {
            return false
