pokeb / asi-http-request

Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone
http://allseeing-i.com/ASIHTTPRequest
Other
5.78k stars 1.41k forks source link

ASIHTTPRequest cannot connect to JIRA with os_authType=basic #407

Open jigsw opened 7 years ago

jigsw commented 7 years ago

I've been trying, and failing, to use Vienna to connect to JIRA's activity log RSS feed. I've seemingly tracked the problem down to line 1000 of ASIHTTPRequest.m:

if ([credentials objectForKey:@"Authentication"]) {

Dumping the credentials object shows that it is non-null, but its status is "Failed" (I've replaced the real URL with myjira, and the username and password):

2016-08-19 17:59:26.797 Vienna[12876:5863347] credentials = {
    Authentication = "<CFHTTPAuthentication 0x6180001e1f00>{state = Failed; scheme = OAuth, forProxy = false}";
    AuthenticationRealm = "http%3A%2F%2Fmyjira%3A8080";
    AuthenticationScheme = OAuth;
    Credentials =     {
        kCFHTTPAuthenticationPassword = "password";
        kCFHTTPAuthenticationUsername = username;
    };
    URL = "http://myjira:8080/activity?maxResults=500&os_authType=basic&title=undefined";
}

So, I've replaced line 1000 of ASIHTTPRequest with:

CFHTTPAuthenticationRef auth = (CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"];
if (auth && CFHTTPAuthenticationIsValid(auth, nil)) {

And it now works - it connects to JIRA fine. It obviously doesn't do anything with the error yet (I've just passed nil), but is this solution along the right lines?

Many thanks, James