         }
     }
 
-    func loginServiceSuccess(_ credential: OAuthSwiftCredential, _ response: OAuthSwiftResponse?, _ parameters: OAuthSwift.Parameters) {
-        guard let loginService = self.loginService, let service = loginService.service, let scope = loginService.scope else { return }
-        guard let loginToken = self.loginCredentialToken else { return }
-        guard let loginSecret = self.loginCredentialSecret else { return }
+    func loginWithCustomOAuth(token: String, secret: String) {
         let params = [
             "oauth": [
-                "credentialToken": loginToken,
-                "credentialSecret": loginSecret
+                "credentialToken": token,
+                "credentialSecret": secret
                 ] as [String: Any]
-            ]
+        ]
 
         AuthManager.auth(params: params, completion: self.handleAuthenticationResponse)
     }
 
+    func loginServiceSuccess(_ credential: OAuthSwiftCredential, _ response: OAuthSwiftResponse?, _ parameters: OAuthSwift.Parameters) {
+
+    }
+
     func loginServiceFailure(_ error: OAuthSwiftError) {
-        alert(title: "Error", message: ((error.errorUserInfo[NSLocalizedDescriptionKey] ?? "") as? String) ?? "")
+
     }
 }

        let state = "{\"loginStyle\":\"popup\",\"credentialToken\":\"\(String.random(40))\",\"isCordova\":true}".base64Encoded()
        let handle = oauthSwift.authorize(withCallbackURL: callbackURL, scope: loginService.scope ?? "",
                                          state: state ?? "", success: loginServiceSuccess, failure: loginServiceFailure)
        self.loginService = loginService
    }

    func updateLoginServices(changes: RealmCollectionChange<Results<LoginService>>) {

        handler.targetURL = URL(string: "\(host)\(authorizePath)")
        handler.viewDidLoad()
        navigationController?.pushViewController(handler, animated: true)
        handler.didNavigate = { purl in
            guard let purl = purl else { return false }
            guard var urlComponents = URLComponents(url: purl, resolvingAgainstBaseURL: true) else { return true }

            urlComponents.query = urlComponents.query?.removingPercentEncoding

            guard let url = urlComponents.url else { return true }

            if url.host == callbackURL.host && url.path == callbackURL.path, let fragment = url.fragment {
                let fragmentJSON = JSON(parseJSON: NSString(string: fragment).removingPercentEncoding ?? "")
                self.loginWithCustomOAuth(token: fragmentJSON["credentialToken"].string ?? "", secret: fragmentJSON["credentialSecret"].string ?? "")
                return true
            }
            return false
