2012-10-26 49 views
0

我幾乎可以做一切與Dropbox的框架連接,斷開連接,下載等。我想獲得訪問令牌,但下面的方法在.m文件的一個返回null如何獲得訪問令牌的Dropbox用戶IOS

//try to get access token 
    MPOAuthCredentialConcreteStore *credentials=[[MPOAuthCredentialConcreteStore alloc] init]; 
    NSLog(@"access token %@",credentials.accessToken); 

任何想法如何獲得用戶訪問令牌?

回答

1

您可能沒有獲得的accessToken但你可以得到用戶信息

[self.restClient loadAccountInfo]; 



- (void)restClient:(DBRestClient*)client loadedAccountInfo:(DBAccountInfo*)info { 
    NSLog(@"UserID: %@ %@", [info displayName], [info userId]); 
} 
+0

謝謝,ü保存我的時間:) –

0

您可以通過此委託讓你的訪問令牌.....

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{ 

    if ([[DBSession sharedSession] handleOpenURL:url]) 
    { 
     if ([[DBSession sharedSession] isLinked]) 
     { 
      // At this point you can start making API calls 

      NSLog(@"App linked successfully!"); 
    } 
    // Add whatever other url handling code your app requires here 
    } 
    return NO; 
} 

返回的URL有訪問令牌,密令牌和用戶ID

+1

'url'包含'oauth_token','oauth_token_secret'和'uid'。 – Joony