Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

objective c - iOS Dropbox SDK - Cannot upload or get metadata

This app used to work properly, but now I cannot upload a file or get metadata. Whenever I try to upload, I'll get

File upload failed with error: Error Domain=dropbox.com Code=401 "The operation couldn’t be completed. (dropbox.com error 401.)" 

But when trying to get metadata I'll get

Error loading metadata: Error Domain=dropbox.com Code=403 "The operation couldn’t be completed. (dropbox.com error 403.)" 

I've been trying to re-authenticate, but there seems to be no difference after I execute unlink command. I've tried placing this command in different places.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//[[DBSession sharedSession] unlinkAll];
DBSession *dbSession = [[DBSession alloc]
                        initWithAppKey:@"**********" //AppKey
                        appSecret:@"************" //Secret
                        root:kDBRootDropbox]; // kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];
[[DBSession sharedSession] unlinkAll];
return YES;
}

It also seems like it's not accessing the authentication flow method thing:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url sourceApplication:(NSString *)source annotation:(id)annotation {
if ([[DBSession sharedSession] handleOpenURL:url]) {
    if ([[DBSession sharedSession] isLinked]) {
        NSLog(@"App linked successfully!");
        // At this point you can start making API calls
    }
    return YES;
}
// Add whatever other url handling code your app requires here
return NO;
}

I've been following the instructions in the Dropbox documentation and can't seem to find what's wrong.

EDIT: This is where I call linkFromController inside my ViewController

- (void)viewDidLoad
{
[super viewDidLoad];

self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient.delegate = self;

if (![[DBSession sharedSession] isLinked]) {
    [[DBSession sharedSession] linkFromController:self];
}

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...