2012-06-08 3 views
0
에 GTMOAuth을 구현할 수있는 방법

내가 몇 가지 코드를내가 아이폰 OS

- (GTMOAuthAuthentication *)myCustomAuth { 


NSString *myConsumerKey = @"f964039f2d7bc82054"; // pre-registered with service 
NSString *myConsumerSecret = @"c9a749c0f1e30c9246a3be7b2586434f"; // pre-assigned by service 

GTMOAuthAuthentication *auth; 
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 = @"Custom Auth Service"; 

return auth; 
} 



- (void)signInToCustomService { 

NSURL *requestURL = [NSURL URLWithString:@"http://alpha.easyreceipts.com/api/v1/oauth/request_token"]; 
NSURL *accessURL = [NSURL URLWithString:@"http://alpha.easyreceipts.com/api/v1/oauth/access_token"]; 
NSURL *authorizeURL = [NSURL URLWithString:@"http://alpha.easyreceipts.com/api/v1/oauth/authorize"]; 
NSString *scope = @"http://alpha.easyreceipts.com/api/v1/"; 

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:@"http://alpha.easyreceipts.com/api/v1/"]; 

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

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

을 내가 OAuth는 라이브러리에 다운로드 한이 app..for 내 아이폰 OS에 GTMOAuth를 구현하고 작성해야하지만, 더 내가 구현하는 방법을 모른다 그것을 도와주세요. 제발 나를 도와주세요. 미리 감사드립니다.

답변

0

GTM 라이브러리로 OAuth 인증 시스템을 구현하려면 먼저이 인증서를 받아야합니다. GTMOAuth here의 전체 소스를 찾을 수 있습니다.

둘째, git 리포지토리에서 사용하는 방법의 예를 찾을 수 있습니다. 적어도 인증하는 데 필요한 모든 것을 찾아야합니다. 더 이상 문제가있는 경우 추가 정보를 제공해주십시오.