I know this is a super old thread, however recently I run into an case with this issue. Just in case, if anyone else still curious about how to use AGSJSONRequestOperation to consume a secured service and return JSON back. Here I shared with a snippet of code in swift:
let cred = AGSCredential(user: "user1", password: "user1") let queryParam = ["bbox": "-241.20512466608835,-27.80850864596666,51.688012394341115,67.48206676752923", "f":"pjson"] let dataUrl = NSURL(string: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/MapServer") let op = AGSJSONRequestOperation(URL: dataUrl, resource: "export", queryParameters: queryParam) op.credential = cred! op.completionHandler = { (obj:AnyObject!) -> Void in print("completed return with this JSON: '\(obj)'") } op.errorHandler = { (err:NSError!) -> Void in print(err) } AGSRequestOperation.sharedOperationQueue().addOperation(op) }
Hope this can help.