2013-07-05 2 views
0

Sales Force를 내 앱에 통합하기 위해 ZKForce를 사용하고 있습니다. 지금까지는 성공했지만 지금은 새로 고침 토큰과 관련된 문제에 직면하고 있습니다.Sales Force가 ZKForce를 사용하여 새로 고침 토큰 가져 오기

신청서에서 영업 담당자에게 로그인 할 때 다음을 수행하고 있습니다.

- (void)loginResult:(ZKLoginResult *)result error:(NSError *)error 
{ 
    if (result && !error) 
    { 
     NSLog(@"session id is %@",result.sessionId); 
     [SFAccountManager sharedInstance].coordinator.credentials.accessToken = result.sessionId; 
     NSLog(@"Login Successful"); 
    } 
    else if (error) 
    { 
     UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Connection failed" message:@"Failed connecting to server. Please try again" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     [myAlertView show]; 

    } 
} 

여기서는 액세스 토큰을 설정하고 새로 고침 토큰을 설정하지 않습니다.

나는 샘플의 경우 메모 응용 프로그램을 다운로드하고 그것을 다음에 성공적으로 로그가 있습니다. 여기가 새로 고침 토큰을 설정하는에서

- (void)loginOAuth:(FDCOAuthViewController *)oAuthViewController error:(NSError *)error 
{ 
    if ([oAuthViewController accessToken] && !error) 
    { 
     NSLog(@"Logged in to Salesforce"); 
     [[FDCServerSwitchboard switchboard] setClientId:kSFOAuthConsumerKey]; 
     [[FDCServerSwitchboard switchboard] setApiUrlFromOAuthInstanceUrl:[oAuthViewController instanceUrl]]; 
     [[FDCServerSwitchboard switchboard] setSessionId:[oAuthViewController accessToken]]; 
     [[FDCServerSwitchboard switchboard] setOAuthRefreshToken:[oAuthViewController refreshToken]]; 
     NSLog(@"oauth token is %@",[oAuthViewController accessToken]); 
     NSLog(@"oauth token is %@",[oAuthViewController refreshToken]); 
     [self.splitViewController dismissModalViewControllerAnimated:YES]; 
     [self.oAuthViewController autorelease]; 

     // STEP 3 b - Save OAuth data after login 
     [self saveOAuthData: oAuthViewController]; 

     [self didLogin]; 
    } 
    else if (error) 
    { 
     [CaseMemoAppDelegate errorWithError:error]; 
    } 
} 

.

내 코드에서 새로 고침 토큰을 얻으려면 어떻게해야합니까? 도와주세요. 감사합니다.

답변

0

새로 고침 토큰은 표준 로그인이 아닌 OAuth 플로우에만 관련이 있습니다. 첫 번째 작품이 표준 로그인 (직접 제출 한 사용자 이름/비밀번호)을 사용하는 경우 새로 고침 토큰을받지 못합니다. OAuth를 사용하면 기본적으로 서버에 처음 로그온 할 때 새로 고침 토큰을 표시하고 현재 액세스 토큰이 만료 될 때 필요한 새 액세스 토큰을 다시 가져올 수 있습니다.

+1

만료 여부를 확인하는 방법 ??? 내가 얻을 수있는 액세스 토큰에 로그인 할 때마다 동일합니다. 하지만 오랜 시간 동안 앱을 유휴 상태로 유지하고 데이터에 액세스하려고 시도하면 오류가 발생합니다. –

관련 문제