Hi All
I'm using OAuth/xAuth in an iPhone twitter app, and having a problem with passwords that contain special characters. For example "password&". First off, I am converting the & into %26 by doing:
NSString *encodedPassword = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)thePassword,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );
This encodes it fine into "password%26". I am then setting it up as a parameter of an OAMutableURLRequest:
[request setParameters:[NSArray arrayWithObjects:
[OARequestParameter requestParameterWithName:@"x_auth_mode" value:@"client_auth"],
[OARequestParameter requestParameterWithName:@"x_auth_username" value:encodedUsername],
[OARequestParameter requestParameterWithName:@"x_auth_password" value:encodedPassword],
nil]];
Upon sending the request using an OADataFetcher, I receive an NSUrlError:
Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x4823e00 "Operation could not be completed. (NSURLErrorDomain error -1012.)"
What am I doing wrong here? If I leave the & in the password it crashes my code (the setParamaters array flunks out). Has anyone come across this before using OAuth?
If I have a alphanumeric password everything works fine... Thanks for any guidance!