ios - Dropbox sdk 401 Error getting for iPhone 5 but not in iPhone 6 for the same app in Xcode 6

标签 ios dropbox-api

我引用了下面的 url 并尝试解决问题,但仍然无法解决问题。 请帮帮我。

Dropbox SDK 401 Error

我的应用程序在 iPhone 6 上运行,但在 iPhone 5 或 5s 上运行相同的应用程序时显示错误:

[WARNING] DropboxSDK: error making request to /1/metadata/dropbox/ALLCREW.TXT - (401)           No auth method found.
2014-12-11 16:58:14.628 user_schedule_3[2331:112832] Error loading metadata: Error   Domain=dropbox.com Code=401 "The operation couldn’t be completed. (dropbox.com error   401.)" UserInfo=0x7fbb50d851c0 {path=/ALLCREW.TXT, error=No auth method found.}.

代码如下: AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions
{
// Override point for customization after application launch.
DBSession *dbSession = [[DBSession alloc]
                        initWithAppKey:@"******h4xl9l4o"
                        appSecret:@"*******1ujh8"
                        root:kDBRootDropbox]; // either kDBRootAppFolder or   kDBRootDropbox
[DBSession setSharedSession:dbSession];
 // NSString *listValue = @"NAME";
 return YES;
}


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

View Controller :

   - (IBAction)didPressLink {
   if (![[DBSession sharedSession] isLinked]) {
    [[DBSession sharedSession] linkFromController:self];
    NSLog(@"did press link is linked");
 } else {
    NSLog(@"did press link is reached");
 }
 }



  NSString *filename = @"ALLCREW.TXT";
 NSString *localDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *localPath = [localDir stringByAppendingPathComponent:filename];
[self.restClient loadMetadata:@"/ALLCREW.TXT"];
//[self.restClient loadFile:@"/ALLCREW.TXT" intoPath:localPath];
NSString *contentOfFile = [NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:nil];
NSArray *stringWithEnter = [contentOfFile componentsSeparatedByString: @"\n"];



- (void)restClient:(DBRestClient *)client
loadMetadataFailedWithError:(NSError *)error {
NSLog(@"Error loading metadata: %@", error);
}



- (void)restClient:(DBRestClient *)client loadedFile:(NSString *)localPath
   contentType:(NSString *)contentType metadata:(DBMetadata *)metadata {
NSLog(@"File loaded into path: %@", localPath);
[self getEntry ];
[self.tableView reloadData];
[spinner stopAnimating];
self.navigationItem.rightBarButtonItem.enabled = true;
}



- (void)restClient:(DBRestClient *)client loadFileFailedWithError:(NSError *)error {
NSLog(@"There was an error loading the file: %@", error);
}

最佳答案

我遇到了同样的问题。解决方案最终是您必须添加:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    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;
}

你似乎有这段代码:

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

将代码移动到 handleOpenURL: 应该可以解决这个问题。

还要确保链接 Security.framework!

来源:http://innofied.com/integration-of-dropbox-in-ios-applications/

关于ios - Dropbox sdk 401 Error getting for iPhone 5 but not in iPhone 6 for the same app in Xcode 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27425268/

相关文章:

ios - 覆盖 setContentOffset

javascript - 使用 Google Drive 以结构化格式存储应用程序数据 - 类似于 Dropbox 数据存储 API

java - Dropbox Java : Use Proxy with authentication

ios - 将 UIButton 放在 UIView 的顶部

ios - Swift - 扩展表格 View ,无需 Storyboard转场

ios - 如何在 CAShapeLayer 中制作动态 strokeColor?在 swift

javascript - 将使用canvas创建的base64图像转换为二进制数据并发布到Dropbox API

javascript - 链接未显示在保管箱选择器应用程序中

php - 从保管箱下载文件到服务器

ios - 在uitableview中显示更多内容