请求标题:接受:/授权:基本XCODE

时间:2014-08-16 13:39:40

标签: ios objective-c http-headers afnetworking

我必须使用登录做一个应用程序。用户可以重置通行证。当他这样做时,会向用户发送带有临时密码的电子邮件。我的问题是:如何包含这个:授权标题格式: 授权:基本toBase64(用户名:密码哈希)

请求标题:

Accept: */* 
Authorization: Basic bWFybGU6JDJ5JDA3JG0wNGtMMjJ6TlZBTVV0RGEwLkVjUk9HaFRhb

VJDNjRhZFk0MzFKQWppT3FJQlV4TDQ0MDVD。

我有updatePasword的方法:

+ (void)updatePassword:(NSString *)password succes:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure {
    NSString *urlString=[NSString stringWithFormat:@"%@/user/%@", BASE_URL,         [SessionHelper currentSession].currentUserID];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:[SessionHelper currentSession].currentUser.username password:[SessionHelper currentSession].currentPasswordHash];

    [manager PUT:urlString parameters:@{@"password":password} success:success failure:failure];
}

当我想更改密码时,会发生这种情况:

2014-08-16 16:24:19.778 ******[1052:60b] sending request: PUT http://*******.my.phpcloud.com/WS/user/61
2014-08-16 16:24:19.779 *******[1052:60b] request body: {"password":"passWORD1"}
2014-08-16 16:24:20.675 *****[1052:6517] request: PUT http://********.my.phpcloud.com/WS/user/61
2014-08-16 16:24:20.676 *******[1052:6517] received error: Request failed: unauthorized (401), got 34845072

如何使此授权?

0 个答案:

没有答案