I have the following steps completed in the OAuth process:
1) Request token
2) Authorize token
3) Receive PIN number
What I can't get to work is getting the access token with the PIN I receive. It always hits my accessTokenTicket:didFailWithError
selector.
Here's the URL that's getting passed to it:
http://www.formspring.me/oauth/access_token?oauth_token=TOKEN_KEY_HERE&oauth_verifier=PIN_HERE
And here's the code that's being called:
- (void)successfulAuthorizationWithPin:(NSString *)pin {
NSLog(@"successfulAuthorizationWithPin:%@", pin);<br>
OAMutableURLRequest *request;<br>
OADataFetcher *fetcher;
NSURL *url = [NSURL URLWithString:kOAuthAccessTokenURL];
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];
OARequestParameter *p1 = [[OARequestParameter alloc] initWithName:@"oauth_verifier"
value:pin];
NSArray *params = [NSArray arrayWithObjects:p0, p1, nil];
[request setParameters:params];
[request prepare];
NSLog(@"%@", request.URL);
fetcher = [[[OADataFetcher alloc] init] autorelease];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(accessTokenTicket:didFinishWithData:)
didFailSelector:@selector(accessTokenTicket:didFailWithError:)];
[p0 release];
[p1 release];
}
And the didFail
method (just an NSLog
of the error) produces this error:
Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x6160c20 {NSErrorFailingURLKey=http://www.formspring.me/oauth/access_token?oauth_token=TOKEN_KEY_HERE&oauth_verifier=PIN_HERE, NSErrorFailingURLStringKey=http://www.formspring.me/oauth/access_token?oauth_token=TOKEN_KEY_HERE&oauth_verifier=PIN_HERE, NSUnderlyingError=0x61321f0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)"}
Am I formatting the URL wrong or supplying wrong or not enough parameters?
Thanks!
John
Did you check if the oauth token generated was correct? I would suggest starting there. Here's a good resource to check your OAuth tokens.
The message comes up if there is an authentication error. Generate the URL via the Netflix Oauth verification and run it on a browser. See if it loads then.