简体   繁体   中英

Authenticating Dropbox in iOS

I am adding Dropbox support to my iOS application. Using the official Dropbox API and the tutorials online here I have gotten to the point where Dropbox needs to be authenticated. The code below is what is given to Authenticate when a button is pressed:

//MainViewController.m
....
@implementation CryptoMainViewController
.....
#pragma mark - Dropbox
- (void)didPressLink {
    if (![[DBSession sharedSession] isLinked]) {
        [[DBSession sharedSession] link];
    }
}

But no matter how I change the code, where I put it or what button I link it to, nothing will happen. Using breakpoints I've found that the method does in-fact get triggered. I've even put it in an IBAction, but this gives the same result. What am I doing wrong? How can I get my app to authenticate the end-user?

And, once authenticated, How can I save an NSString to the user's Dropbox?

If this is just totally wrong, then where can I go to find resources on how to do this properly?

The whole tutorial, all of the documentation, api, etc. is available here .

I had the same problem; the reason was that I hadn't set the shared Dropbox session, eg

DBSession* dbSession = [[[DBSession alloc] initWithAppKey: @"your_app_key"
                                           appSecret: @"your_app_secret"
                                           root: kDBRootAppFolder] autorelease];
[DBSession setSharedSession: dbSession];

Once that was called the link worked fine.

this answer may be late but im guessing that you already linked your app before and want to do so again. The only way you can have the process of linking taking place again is if you run the following code: [[DBSession sharedSession] unlinkAll]; You can place it in your viewDidLoad. When you then call didPressLink: the app should open up dropbox app(if available), safari or an in app window asking for your permission to access your dropbox. If this does not happen then the problem is somewhere else. Hope this helps

Does your view implement the <DBLoginControllerDelegate> ?

If so, link Dropbox like so:

DBLoginController* controller = [[DBLoginController new] autorelease];
        controller.delegate = self;
        [controller presentFromController:self];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM