views:

139

answers:

1

Hi,

I am developing an iPhone app that uses Twitvid library for uploading videos to TwitVid. This library first authenticates the app using the user-name and password input parameters. Then it uploads the video. But, recently I switched to OAuth mechanism of authentication which leads to a web-page where user can enter the user-name and password. So, I cannot provide the input fields for user-name and password in my app for uploading video.

Can someone help me out to solve this problem.

Thanks and Regards, Deepa

+2  A: 

Hi,

I think you have used "SA_OAuthTwitterEngineDelegate" for Oauth. If then replace below method with existing method in "SA_OAuthTwitterController.m" file. I think this will helpful.

> - (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest: (NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType { NSData *data = [request HTTPBody];

char                *raw = data ? (char *) [data bytes] : "";

if (raw && strstr(raw, "cancel=")) {
    [self denied];
    return NO;
}
else if ([[[request URL] absoluteString] isEqualToString:@"http://twitter.com/oauth/authorize"]) {
    NSString *str = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
    NSRange range = [str rangeOfString:@"password"];
    NSLog(@"%d",range.location);
    if (range.location != NSNotFound ) {
        NSString *strPass = [str substringFromIndex:range.location+8];
        NSRange toRang = [strPass rangeOfString:@"&oauth_token="];
        strPass = [strPass substringToIndex:toRang.location];
        NSArray *tempArray = [strPass componentsSeparatedByString:@"="];
        if ([tempArray count]) {
            strPass = [tempArray objectAtIndex:1];
            NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
            [defaults setObject:strPass forKey:@"pass"];
        }
    }
}
if (navigationType != UIWebViewNavigationTypeOther) 
    _webView.alpha = 0.1;
return YES;

}

Cheers, Pragnesh

Pragnesh Dixit