Changes made to support AFNetworking 2.0 #55
Conversation
Please accept this one. |
This is like a game - support AFNetworking 2.0=))) Makes me laugh=))))) |
Of course I already did that, just pointing out to the maintainers that this pull request if worth accepting. |
I think, that this library has one "fatal lack" - it can not be applied to two entities (AFHTTPSessionManager and AFHTTPRequestOperationManager) at once. It must be rewrited twice(!). Sooo... We must abstract from "request level" and make it as independent class. |
@mlwelles Can you update the podspec to require AFNetworking 2.0? It's linking against 1.x now |
Can we please accept one of these |
bump |
Change the podspec to support AFNetworking 2.0.
I'm currently using the result of this pull request in a rather complex app and it seems good to go. I had to change some minor things to make it work for my case, but I think they could be used in general, so here's something you might want to add/change:
|
👍 |
How do I use the custom podspec file to incorporate this pull into my project? |
pod 'AFOAuth2Client', :git => 'https://github.com/mlwelles/AFOAuth2Client' |
This makes AFOAuth2Client compile against AFNetworking 2.0, but I feel like it requires additional changes to make it support AFNetworking 2.0 better. For example: setting the bearer token as a header on the OAuth client itself is old behavior, and should not be used anymore. Instead, the OAuth client should be used to obtain a credential that is then used in a standard client. This is pretty easy to implement in AFNetworking 2.0, by writing an - (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
withParameters:(NSDictionary *)parameters
error:(NSError *__autoreleasing *)error {
request = [super requestBySerializingRequest:request withParameters:parameters error:error];
if (self.credential) {
NSMutableURLRequest *mutableRequest = [request mutableCopy];
if ([self.credential.tokenType compare:@"Bearer" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
[mutableRequest setValue:[@"Bearer " stringByAppendingString:self.credential.accessToken] forHTTPHeaderField:@"Authorization"];
}
request = [mutableRequest copy];
}
return request;
} I do, however, agree that |
added response object to auth call
Would be good to see this merged in so I dont have to point at a different repo |
See #79 (comment). |
Based on pull request #50 that's still pending from @nilsou. Found it needed a few more tweaks to get working properly.