2012-02-14 4 views
0

私はiPhoneアプリを持っています。私はGTMOAuthViewControllerTouchを使用してtripitサポートを追加しようとしています。私は、公式ドキュメントを読んでいたと私は要求、アクセスおよびauthotize URLが見つかりましたが、それは¿「スコープ」とOAuthCallbackのURLについては何も話していないTripit + GTMOAuthViewControllerTouch

NSString *myConsumerKey = kTripItAPIKey;  // pre-registered with service 
NSString *myConsumerSecret = kTripItAPISecret; // pre-assigned by service 

GTMOAuthAuthentication *auth = [[[GTMOAuthAuthentication alloc] initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1 
                      consumerKey:myConsumerKey 
                      privateKey:myConsumerSecret] autorelease]; 

// setting the service name lets us inspect the auth object later to know 
// what service it is for 
auth.serviceProvider = @"Tripit"; 

NSURL *requestURL = [NSURL URLWithString:@"https://api.tripit.com/oauth/request_token"]; 
NSURL *accessURL = [NSURL URLWithString:@"https://api.tripit.com/oauth/access_token"]; 
NSURL *authorizeURL = [NSURL URLWithString:@"https://m.tripit.com/oauth/authorize"]; 
NSString *scope = @"https://api.tripit.com/scope"; 

GTMOAuthAuthentication *auth = [self myCustomAuth]; 

// set the callback URL to which the site should redirect, and for which 
// the OAuth controller should look to determine when sign-in has 
// finished or been canceled 
// 
// This URL does not need to be for an actual web page 
[auth setCallback:@"https://api.tripit.com/OAuthCallback"]; 

// Display the autentication view 
GTMOAuthViewControllerTouch *viewController = [[[GTMOAuthViewControllerTouch alloc] initWithScope:scope 
                         language:nil 
                        requestTokenURL:requestURL 
                       authorizeTokenURL:authorizeURL 
                        accessTokenURL:accessURL 
                        authentication:auth 
                        appServiceName:@"AppName" 
                         delegate:self 
                       finishedSelector:@selector(viewController:finishedWithAuth:error:)] autorelease]; 

[[self navigationController] pushViewController:viewController 
             animated:YES]; 

:?それは4 NSURLを使用しています。アクセスしようとすると、Tripitサイトから「アクセス要求失敗」というメッセージが表示されます。どうしましたか?

答えて

0

:-(私は他の誰が同じ問題に遭遇した場合に、これをお答えします。

あなたは少しはTripItでそれを使用するには、Googleのプロジェクトを変更する必要があります。TripItのは、同様に、oauth_tokenを送信するためにあなたを期待しています要求URLでoauth_callbackとしてのUIWebViewはTripItのサーバーに送信されている正確に何を見るためにロードされていることを、要求をログ

あなたのケースでは、それはおそらく次のようになります。。とき

https://m.tripit.com/oauth/authorize?oauth_token=<THE TOKEN HERE> 

次のようになります。

https://m.tripit.com/oauth/authorize?oauth_token=<THE TOKEN HERE>&oauth_callback=<YOUR CALLBACK URL> 

元の要求にコールバックURLを追加して、あなたは、ログインが/画面の読み込みを許可する確認する必要があり、代わりの「アクセス要求が失敗しました」。

また、TripItとOAuth 1.0との統合について混乱している人を助けるかもしれません。 http://blog.andydenmark.com/2009/03/how-to-build-oauth-consumer.html