2014-01-30 3 views
0

나는 여기서 뭔가를 놓친 것 같아.oAuth2Client 토큰을 라이브러리에 전달하는 방법

내 앱으로 https://github.com/nxtbgthng/OAuth2Client을 설정하려고합니다.

어떻게 oauth 토큰을 라이브러리에 전달해야하는지 이해할 수 없습니다.

내가 전화 :

[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"]; 

나는 성공적으로 토큰을 얻을 :

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url 
    sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; 

은 어떻게 라이브러리에 토큰을 전달합니까?!

답변

1

한 통화가 밝혀 :에

[[NXOAuth2AccountStore sharedStore] handleRedirectURL:url]; 

:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; 
1

OAuthToken을 사용하여 요청을 호출하려면 NXOAuth2Request를 사용해야합니다. github 페이지의 예제 코드는 아래와 같습니다. 토큰은 NXOAuth2Account 클래스에 의해 랩됩니다. NXOAuth2Account 클래스는 차례로 NXOAuth2AccountStore 싱글 톤에 래핑됩니다.

[[NXOAuth2AccountStore sharedStore] accounts] 

계정 배열을 반환합니다.

다음 방법으로 매개 변수로 계정을 사용하여 인증 된 API 호출을 만들 수 있습니다.

[NXOAuth2Request performMethod:@"GET" 
       onResource:[NSURL URLWithString:@"https://...your service URL..."] 
      usingParameters:nil 
       withAccount:anAccount 
     sendProgressHandler:^(unsigned long long bytesSend, unsigned long long bytesTotal) { // e.g., update a progress indicator } 
      responseHandler:^(NSURLResponse *response, NSData *responseData, NSError *error){ 
       // Process the response 
      }]; 
+0

내가 [[NXOAuth2AccountStore sharedStore] 계정]을 확인. 그러나이 시점에서는 계정이 생성되지 않습니다. 먼저 AccessToken으로 초기화해야합니다. 액세스 토큰을 가지고 있지만 지금은 라이브러리에 전달하여 계정이 만들어 지도록하는 방법이 없습니다. ( – 1b0t

+0

NSString으로 토큰을 가졌습니다. 내 문제는 어떻게 해야할지 모르겠다는 것입니다. NXOAuthAccount의 init 메소드가 private 인 것처럼 토큰에서 계정을 작성하십시오. – 1b0t

관련 문제