RestKit: How to resubmit failed request after re-authenticating?

后端 未结 1 1344
清酒与你
清酒与你 2021-01-21 22:53

The API I\'m developing against requires me to present an authentication token in a custom HTTP header. This token expires every few minutes, and could happen while the user is

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-21 23:36

    Catch it in Failure block , and check for the status code and re-do the authentication

        RKObjectRequestOperation *requestOp = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[getObjResp]];
    
                [requestOp setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
                    ....
                    }
                } failure:^(RKObjectRequestOperation *operation, NSError *error){
    // Here your status code check                
    // Here your retry-code
                    }
    

    0 讨论(0)
提交回复
热议问题