Integrate Dropbox in ios app, but without login po

2020-08-04 08:53发布

问题:

I want to integrate Dropbox in my app. I have made one sample example using Dropbox document and sample code.

But the issue is, I don't want to open login popup. So is there any way so that I can use dropbox without login or some where I can set default login ID Password and automatically do login. so that I can use dropbox directly.

Thanks,

Hardik Shah

回答1:

Well you could put the files in Dropbox and then share them and use the shared URLs as resources to call. We actually do this for some of our developer blog assets. Hope that helps. Careful not to move the files otherwise the links will break.



回答2:

I used DropBox Core API and generated access token. That worked fine with me.

NSString *surl = @"https://api.dropbox.com/1/metadata/dropbox/";

NSURL *url = [[NSURL alloc] initWithString:surl];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:url];

[req setValue:[self getAuth] forHTTPHeaderField:@"Authorization"];

NSURLSessionConfiguration *config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
[config setHTTPAdditionalHeaders:@{@"Authorization": @"Bearer xxxxxxxxxxxxxxxxxxxx"}];  // replace xs with you access token

NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:req delegate:self];

of course you need to handle NSURLConnectionDelegate protocol

that example gives you all files and folders at your dropbox account root