Darren
Darren

Reputation: 1133

What's the proper and correct way to access files on O365 from iOS

I know that someone mean will probably close this question for being opinion, but the truth is, I'm not after opinion as such, but actual facts about the correct way and how to do this.

I've been searching around for quite a time and I'm still unclear as to what direction to take. It seems there are a billion* libraries that I could use, but I want to know what would be the correct, proper supported method of achieving this.

Essentially, I have a very simple requirement to list and download files from Sites on our Office 365 subscription to an iOS application.

Initially, I looked at the REST interface for Sharepoint and, from a browser, was able to easily perform a GET to our site and receive and receie a response with meta data about the file, for example:

https://mytenantid.sharepoint.com/_api/web/getfilebyserverrelativeurl('/MyFile/Here/Document.txt')

I could also retrieve JSON output instead of XML by specifying an Accept header of application/json using the POSTMAN REST client for Chrome.

So far, so easy. Just the authentication to do outside of the browser and that's it.

Phew!!

I started by looking at Basic authentication, but wasn't sure if this is the right way to do it and even if it would work?

On looking further, it seems that actually, using OAuth might be the way to go. Apparently, you can either do this yourself (no idea how), or use a library (ADAL?) from Microsoft? Unfortunately, this all looks half baked will very little documentation that seems to work. It also requires the use of CocoaPods and workspaces and isn't just a simple library that I can copy to my project and start using (a la SwiftyJSON). There also seems to be a lot of other libraries around too.

I should mention that I'm using Swift, so I've tried converting code from Objective C to Swift (unsuccessfully) too. Apparently I can't use "readWithCallback" with an argument list that the code tells me I should actually use -- even a sample application I downloaded had the same issue.

I've also tried using node.js with a script (not a Web Application) and the documentation and number of libraries available for that is almost worse.

Any assistance to achieve this really simple capability would be hugely appreciated -- it's been driving me nuts.

Many thanks, D.

*this might be a slight exaggeration.

Upvotes: 0

Views: 149

Answers (1)

Mostafa
Mostafa

Reputation: 3302

Office 365 has a RESTful API that you can use any programming language to authentication and integrate in your app.

Here is a simple example for iOS connected app to office 365. The sample shows how to do this in Objective C and SWIFT.

https://github.com/OfficeDev/O365-iOS-Connect

If you want to full iOS samples for office 365 connected apps, Check out this link: https://msdn.microsoft.com/en-us/office/office365/howto/starter-projects-and-code-samples

Enjoy :)

Upvotes: 1

Related Questions