ashapangare / oauthconsumer

Automatically exported from code.google.com/p/oauthconsumer
0 stars 0 forks source link

Unable to pass through last step in vimeo oAuth authentication #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Replace 3 urls as:
Request Token:
    http://vimeo.com/oauth/request_token
User Authorization:
    http://vimeo.com/oauth/authorize
Access Token:
    http://vimeo.com/oauth/access_token

For getting access token, get verifier and authorized token from webview 
request when the app is redirected to callback in the "User Authorization step".

Pass these as parameters to http://vimeo.com/oauth/access_token as follows:
- (void)successfulAuthorizationWithToken:(NSString *)token verifier:(NSString 
*)verifier  {
    OAMutableURLRequest *request;
    OADataFetcher *fetcher;

    NSURL *url = [NSURL URLWithString:@"http://vimeo.com/oauth/access_token"];
    request = [[[OAMutableURLRequest alloc] initWithURL:url
                                               consumer:self.consumer
                                                  token:nil
                                                  realm:nil
                                      signatureProvider:nil] autorelease];

    OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:@"oauth_token"
                                                                value:token];
    OARequestParameter *p1 = [[OARequestParameter alloc] initWithName:@"oauth_verifier"
                                                                value:verifier];
    NSArray *params = [NSArray arrayWithObjects:p0, p1, nil];
    [request setParameters:params];

    fetcher = [[[OADataFetcher alloc] init] autorelease];

    [fetcher fetchDataWithRequest:request
                         delegate:self
                didFinishSelector:@selector(accessTokenTicket:didFinishWithData:)
                  didFailSelector:@selector(accessTokenTicket:didFailWithError:)];

    [p0 release];
    [p1 release];

}

What is the expected output? What do you see instead?

App returns following error is selector (accessTokenTicket:didFailWithError:):
Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be 
completed. (NSURLErrorDomain error -1012.)" UserInfo=0xe2aab40 
{NSErrorFailingURLKey=http://vimeo.com/oauth/access_token?oauth_token=c033e428a2
f07516edc82f11f48de7c3&oauth_verifier=category-2108815695, 
NSErrorFailingURLStringKey=http://vimeo.com/oauth/access_token?oauth_token=c033e
428a2f07516edc82f11f48de7c3&oauth_verifier=category-2108815695, 
NSUnderlyingError=0xe2a57f0 "The operation couldn’t be completed. 
(kCFErrorDomainCFNetwork error -1012.)"}

App should go to selector(accessTokenTicket:didFinishWithData:)

What version of the product are you using? On what operating system?
It's an iPad app

Please provide any additional information below.
App has callback registered during registration. 

Here are the other two requests for getting request token and authorization

- (IBAction)authenticateButtonAction {
    NSLog(@"authenticateButtonAction");
    OAMutableURLRequest *request;
    OADataFetcher *fetcher;

    //NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/oauth/request_token"];
    NSURL *url = [NSURL URLWithString:@"http://vimeo.com/oauth/request_token"];
    request = [[[OAMutableURLRequest alloc] initWithURL:url
                                               consumer:self.consumer
                                                  token:nil
                                                  realm:nil
                                      signatureProvider:nil] autorelease];

    [request setHTTPMethod:@"GET"];

    OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:@"oauth_callback" value:@"oob"];

        NSArray *params = [NSArray arrayWithObject:p0];
        [request setParameters:params];

    fetcher = [[[OADataFetcher alloc] init] autorelease];

    [fetcher fetchDataWithRequest:request
                         delegate:self
                didFinishSelector:@selector(requestTokenTicket:didFinishWithData:)
                  didFailSelector:@selector(requestTokenTicket:didFailWithError:)];

}

- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData 
*)data {

    if (ticket.didSucceed) {
        OAMutableURLRequest *request;
        NSString *responseBody = [[NSString alloc] initWithData:data
                                                       encoding:NSUTF8StringEncoding];

        if (self.accessToken != nil) {
            [self.accessToken release];
            self.accessToken = nil;
        }

        self.accessToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
        [responseBody release];

        //NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/oauth/authorize"];
        NSURL *url = [NSURL URLWithString:@"http://vimeo.com/oauth/authorize"];
        request = [[[OAMutableURLRequest alloc] initWithURL:url
                                                   consumer:self.consumer
                                                      token:self.accessToken
                                                      realm:nil
                                          signatureProvider:nil] autorelease];

        OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:@"oauth_token"
                                                                    value:self.accessToken.key];
        NSArray *params = [NSArray arrayWithObject:p0];
        [request setParameters:params];
        //[request prepare];

        AuthorizeWebViewController *vc;
        vc = [[AuthorizeWebViewController alloc] initWithNibName:@"AuthorizeWebViewController" bundle:nil];
        vc.delegate = self;
        [self presentModalViewController:vc animated:YES];
        [vc.webView loadRequest:request];

        [vc release];
        [p0 release];
    }
    else {

    }

}

Original issue reported on code.google.com by loril...@gmail.com on 12 May 2011 at 8:30