使用Alamofire从Swift访问Django Rest框架API

使用Alamofire从Swift访问Django Rest框架API,django,swift,rest,django-rest-framework,alamofire,Django,Swift,Rest,Django Rest Framework,Alamofire,我有一个Django Rest框架API,可以使用curl访问它,如下所示: curl -H 'Accept: application/json; indent4' -u mrigdon:password123 http://localhost:8000/api/users/ 这就行了。我在Swift项目中安装了Alamofire,并希望使用以下代码访问同一端点: Alamofire.request(.GET, "http://localhost:8000/api/users", parame

我有一个Django Rest框架API,可以使用
curl
访问它,如下所示:

curl -H 'Accept: application/json; indent4' -u mrigdon:password123 http://localhost:8000/api/users/
这就行了。我在Swift项目中安装了Alamofire,并希望使用以下代码访问同一端点:

Alamofire.request(.GET, "http://localhost:8000/api/users", parameters: ["mrigdon":"password123"])
        .response { request, response, data, error in
            let jsonData: NSData = data!
            let jsonDict = try! NSJSONSerialization.JSONObjectWithData(jsonData, options: NSJSONReadingOptions.AllowFragments) as! NSDictionary
            print(jsonDict)
}
但是得到这个403响应:

detail = "Authentication credentials were not provided."

有人知道如何正确格式化此Alamofire请求吗?

您的API将如何抛出该错误?在什么情况下?还要记住GET请求参数将在查询字符串中,原因是用户必须是管理员才能访问该端点。您能提供它将采用的格式吗?您的API将如何抛出该错误?在什么情况下?还要记住GET请求参数将在查询字符串中,原因是用户必须是管理员才能访问该端点。你能提供它的格式吗?