Question

I see it's easy to set up basic auth when using a manager, here is a sample: How do I set basic authentication with RestKit 0.20.0? The problem I have is that I create RKManagedObjectRequestOperation and send start. Without a manager. Basically because is a random URL. And in this case, I have no idea about how I can add basic auth. Maybe I have to go down, to AFNetworking or lower. But searching on the net I don't see anything. Do you have any idea or suggestion? Thank in advance.

Was it helpful?

Solution

The basic auth is set as a header, so you need to do that. If you create the operation you should be creating the request so just set it. You can model your code on AFNetworking:

NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password];
[self setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top