2011-02-06 312 views
0

我有以下步驟在OAuth過程完成:
1)請求令牌
2)授權令牌
3)接收的PIN號碼
OAuth訪問令牌請求失敗(NSErrorFailingURLStringKey)

什麼我不能無法開始工作就是使用我收到的PIN碼獲取訪問令牌。它總是擊中我的accessTokenTicket:didFailWithError選擇器。

這裏有一個是越來越傳遞給它的URL:
http://www.formspring.me/oauth/access_token?oauth_token=TOKEN_KEY_HERE&oauth_verifier=PIN_HERE

這裏是一個的被調用的代碼:

- (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]; 
} 

而且didFail方法(只是錯誤的NSLog)產生這個錯誤:

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.)"}

我的網址格式不對,或提供的參數錯誤或不夠?

謝謝!
John

回答

3

您是否檢查生成的oauth標記是否正確?我會建議從那裏開始。 Here's是檢查您的OAuth令牌的好資源。

如果存在認證錯誤,則顯示消息。通過Netflix Oauth驗證生成URL並在瀏覽器上運行。看看它是否加載。