I'm developing an iOS application and using Deployd as backend .The problem is when I send a GET request to users/me with a sid cookie to identify my session, It returns 204-no content, even though user is logged-in. I'm expecting some data in return.
Xcode console output:
<NSHTTPURLResponse: 0x136ed2e00> { URL: http://xxxxxxxxxxxxxxx:2403/users/me?sid=3f53dd6c10...9fc4a00 } { status code: 204, headers {
"Cache-Control" = "no-cache, no-store, must-revalidate";
Connection = "keep-alive";
Date = "Sat, 16 Jan 2016 18:55:16 GMT";
Expires = 0;
Pragma = "no-cache"; } }
So I was sending SID as parameter, It was incorrect. Deployd demands a 'barrier token'.
Swift code:
let url = NSURL(string: "http:/xxxxxxxxxxxxxxxx.com:2403/users/me")
let request = NSMutableURLRequest(URL: url!)
request.HTTPMethod = "GET"
request.setValue( "Bearer \(token!)", forHTTPHeaderField: "Authorization")
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.currentQueue()!) { response, maybeData, error in
if let data = maybeData {
let contents = NSString(data:data, encoding:NSUTF8StringEncoding)
print(contents!, "bitch")
} else {
print(error!.localizedDescription)
}
}