Socket.io-client-swift: How do i send authorization headers?

Created on 31 May 2016  路  1Comment  路  Source: socketio/socket.io-client-swift

How do i send the authorization headers back to the server from IOS.
Currently I'm using socket.io-jwt to check the authorization back in the server.
Because I would only get the token when the user logs in.

How would I approach this problem?

In the documentation for the website, it shows

var socket = io.connect('http://localhost:9000', {
  'query': 'token=' + your_jwt
});

How would I append the token into the connection?

This is what I did

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

    var token: String {
        get {
            return String(keychain["token"])
        }
    }


//    
    lazy var socket: SocketIOClient = SocketIOClient(socketURL: NSURL(string: "https://testing.herokuapp.com")!,
    options: [.Log(true), .ExtraHeaders(["Authorization": "Basic \(self.token)", "Accept":"application/json"]) ])

But seems like it doesn't work.

>All comments

how to send authorisation headers when using socket.io

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Seonift picture Seonift  路  4Comments

harshanakaru picture harshanakaru  路  4Comments

leeyuno picture leeyuno  路  5Comments

elitelokesh picture elitelokesh  路  6Comments

gaetanm picture gaetanm  路  4Comments