secret or public key must be provided - IOS/Swift + Socket.io-JWT
<p>My goal is very simple, authenticate a user via socket.io jwt. So that I could manipulate his/her data in real-time.</p>

<p>Clientside code</p>

<pre><code>import SocketIOClientSwift
import KeychainAccess

class SocketIOManager: NSObject {
    static let sharedInstance = SocketIOManager()

    // 1
    let keychain = Keychain(server: "https://testing.herokuapp.com", protocolType: .HTTPS)

    //2
    var token: String {
        get {
            if let realToken = keychain["token"] {
                return String(realToken)
            } else {
                return ""
            }

        }
    }

    //3
    lazy var socket: SocketIOClient = SocketIOClient(socketURL: NSURL(string: "https://testing.herokuapp.com")!,
                                                     options: [.Log(true), .ConnectParams(["token": self.token])])

    override init() {
        super.init()

    }


    func establishConnection() {
        socket.connect()
    }

    func closeConnection() {
        socket.disconnect()
    }



}
</code></pre>

<p>Just for you guys to understand</p>

<ol>
<li>keychain purpose is just to store the token, let say I already saved
the token from user who logs in, then I will simply do this
<code>keychain["token"] = "token"</code>, lets assume that the token has been
saved</li>
<li><code>var token</code> is to get the token, because currently keychain store
the token in optional, thus i need to do optional binding.</li>
<li>Lastly I instantiate a socket object, so that I could pass the token
as the parameter, many people recommend to do this
<code>.ConnectParams(["token": self.token])</code></li>
</ol>

<p>So far so good, but right now, whenever I try to establish a connection in an app delegate , </p>

<p><strong>AppDelegate.Swift</strong></p>

<pre><code> func applicationDidBecomeActive(application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
        SocketIOManager.sharedInstance.establishConnection()
    }
</code></pre>

<p>I will received</p>

<pre><code>Handling event: error with data: (
        {
        code = "invalid_token";
        message = "secret or public key must be provided";
        type = UnauthorizedError;
    } )
</code></pre>

<p>For clarity, I don't want to include the serverside code because It's just a boilerplate code from this <a href="https://github.com/auth0/socketio-jwt" rel="nofollow">https://github.com/auth0/socketio-jwt</a></p>

<p>So, the real question is, what did I do wrong??</p>