         }
         oauthSwift.authorizeURLHandler = handler
 
-        let state = "{\"loginStyle\":\"popup\",\"credentialToken\":\"\(String.random(40))\",\"isCordova\":true}".base64Encoded()
-        oauthSwift.authorize(withCallbackURL: callbackURL, scope: loginService.scope ?? "",
-                             state: state ?? "", success: { _,_,_  in }, failure: { _ in failure() })
+        oauthSwift.authorize(withCallbackURL: callbackURL, scope: scope,
+                             state: state, success: { _, _, _  in }, failure: { _ in failure() })
     }
 }

            responseType: "token"
        )

        guard let oauthSwift = oauthSwift else { return }

        let handler = WebViewController()
        oauthSwift.removeCallbackNotificationObserver()
        handler.targetURL = URL(string: "\(host)\(authorizePath)")
        handler.viewDidLoad()
        viewController.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 ?? "")

            let clientId = loginService.clientId,
            let authorizePath = loginService.authorizePath,
            let tokenPath = loginService.tokenPath,
            let scope = loginService.scope,
            let callbackURL = callbackURL(for: loginService, at: server),
            let state = state()
        else {
            failure()
            return
        }

