For some purpose I have created singleton that organize all works with dropbox via this new object.
So I have next singleton with initialization code as below:
- (id)init
{
self = [super init];
if (self)
{
self.cloudName = @"Dropbox";
DBSession* dbSession = [[DBSession alloc] initWithAppKey:DP_App_KEY
appSecret:DP_App_SECRET
root:ROOT];
[DBSession setSharedSession:dbSession];
self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient.delegate = self;
}
return self;
}
If you can see I init DBSession directly in my singleton init method. The app call init method and seems everything should work good.
So when I logged in the app calls this in open url method:
if ([[DBSession sharedSession] isLinked])
and app output here that the dropbox is linked, but when I try to to get metadata for root @"/" folder (list of files) and call this method:
[self.restClient loadMetadata:folder];
the app output this error:
[WARNING] DropboxSDK: error making request to /1/metadata/dropbox - (403) Parameter not found: oauth_token
2014-04-25 00:30:15.652 PDF-Notes[75257:70b] Error loading metadata: Error Domain=dropbox.com Code=403 "The operation couldn’t be completed. (dropbox.com error 403.)" UserInfo=0xb666600 {path=/, error=Parameter not found: oauth_token}
But when I rerun app via Xcode one more time everything works good. Also if I set DBSession in app delegate it also works. I really did not understand why it does not work in singleton because the invocation methods works in the same way, but only if we init DBSession in app it works without problems.