0
我有一個表由FOSUserBundle管理與Symfony2應用程序中的用戶。我可以毫無問題地使用cURL訪問受防火牆保護的路由。比方說,我有一個路徑/ API /東西,是受保護的,我想用捲曲訪問它,我用:iOS - 發送身份驗證到FOSUserBundle數據庫不工作,但cURL工作
curl -v -u paul http://example/web/app_dev.php/api/something/
上述工作沒有問題。但是,從我的應用程序,它總是返回一個401:當我使用下面的代碼片段時,您沒有進行身份驗證。我將它轉換爲64位,因爲AFNetworking表示必須採用這種格式。我在想什麼?
NSData *pass = [@"somestring" dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64pass = [pass base64EncodedStringWithOptions:0];
NSData *user = [@"anotherstring" dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64user = [user1 base64EncodedStringWithOptions:0];
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
[self setDefaultHeader:@"Accept" value:@"application/json"];
[self setAuthorizationHeaderWithUsername:base64user password:base64pass];
這是返回的HTTP標頭,AFNetworking不設置標頭。我怎樣才能完成這項任務?
{ status code: 401, headers {
Allow = "GET, POST";
"Cache-Control" = "no-cache";
Connection = "Keep-Alive";
"Content-Type" = "application/json";
Date = "Fri, 31 Jan 2014 14:25:48 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Apache/2.2.22 (Ubuntu)";
"Transfer-Encoding" = Identity;
"X-Debug-Token" = c562ea;
"X-Powered-By" = "PHP/5.3.10-1ubuntu3.9";
}