         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>>) {


    @IBOutlet weak var authButtonsStackView: UIStackView!
    var customAuthButtons = [String: UIButton]()
    var loginService: LoginService?
    var loginCredentialToken: String?
    var loginCredentialSecret: String?

    deinit {
        NotificationCenter.default.removeObserver(self)

        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
