I have basic auth setup and working with Drupal services
, and am using the administrator login. It is returning data for a voting API. When I access the site (with login) it retrieves the details. But on my xcode project, when I query the API as a get command (using services definition http://example.site/ios1/user/ {UID} ) it returns following error.
"access denied for user anonymous".
Any tips?
Solved. I had to select 'http basic authentication' in Drupal services, add 'headers' to the alamofire query, plus my authentication header needed to e:
let user = "example"
let password = "example"
let credentialData = "\(user):\(password)".dataUsingEncoding(NSUTF8StringEncoding)!
let base64Credentials = credentialData.base64EncodedStringWithOptions([])
let headers = ["Authorization": "Basic \(base64Credentials)"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.