OneDrive SDK for iOS

Overview

Get started with the OneDrive SDK for iOS

Build Status

Integrate the OneDrive API into your iOS app!

1. Installation

Install via Cocoapods

  • Install Cocoapods - Follow the getting started guide to install Cocoapods.
  • Add the following to your Podfile : pod 'OneDriveSDK'
  • Run the command pod install to install the latest OneDriveSDK pod.
  • Add #import <OneDriveSDK/OneDriveSDK.h> to all files that need to reference the SDK.

2. Getting started

2.1 Register your application

Register your application by following these steps.

2.2 Set up Keychain Sharing Entitlements in your Xcode Project

Click on your project in the Navigator pane in Xcode. Click on your application target and then the "Capabilities" tab. Scroll down to "Keychain Sharing" and flip the switch on. Add "com.microsoft.adalcache" to that list.

2.2 Setting your application Id and scopes

  • You can set your application Id and scopes directly on the ODClient object.

  • For applications targeting OneDrive call the class method [ODClient setMicrosoftAccountAppId:<applicationId> scopes:<scopes>] with a specified <applicationId> and <scopes>. For more info about scopes, see Authentication scopes.

  • For applications targeting OneDrive for Business call the class method [ODClient setActiveDirectoryAppId:<applicationId> redirectURL:<redirectURL>] with specified <applicationId> and <redirectURL>. Note: the redirect URL must match the redirect URL that you specified in the Azure Management Portal.

2.3 Getting an authenticated ODClient object

  • Once you have set the correct application Id and scopes, you must get an ODClient object to make requests against the service. The SDK will store the account information for you, but when a user logs on for the first time, it will invoke UI to get the user's account information.

  • Get an authenticated ODClient via the clientWithCompletion method:

[ODClient clientWithCompletion:^(ODClient *client, NSError *error){
    if (!error){
        self.odClient = client;
    }
 }];

2.4 Making requests against the service

Once you have an ODClient that is authenticated you can begin to make calls against the service. The requests against the service look like our REST API.

To retrieve a user's drive:

[[[odClient drive] request] getWithCompletion:^(ODDrive *drive, NSError *error){
    //Returns an ODDrive object or an error if there was one
}];

To get a user's root folder of their drive:

[[[[odClient drive] items:@"root"] request] getWithCompletion:^(ODItem *item, NSError *error){
    //Returns an ODItem object or an error if there was one
}];

For a general overview of how the SDK is designed, see overview.

For a complete sample application, see OneDriveAPIExplorer.

3. Documentation

For a more detailed documentation see:

4. Issues

For known issues, see issues.

5. License

License

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Comments
  • App failing when trying to authenticate OneDrive

    App failing when trying to authenticate OneDrive

    My app keeps crashing and this is the stack strace:

    ODServiceInfoProvider getServiceInfoWithViewController:appConfiguration:completion:], /XcodeProjects/Project/Pods/OneDriveSDK/OneDriveSDK/Accounts/ODServiceInfoProvider.m:45 2015-09-27 23:44:19.584 PhotoCal[8800:2364421] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: viewController'

    Can somebody tell me what is going wrong?

    service issue 
    opened by ghost 43
  • GET drive/items/root/children request fails with 400

    GET drive/items/root/children request fails with 400 "bad request" error.

    Hi.

    I have initialized the ODClient with the parameter capability:"Directory". When I try to get the child items of the root element SDK shows me the next error: OneDrive SDK ERROR : Error from data task : Error Domain=com.microsoft.onedrive.errors Code=400 "bad request" UserInfo={error= malformed : (null), NSLocalizedDescription=bad request} 2016-05-11 20:16:41.435 App-iOS2[1279:242395] OneDrive SDK ERROR : Caused by request <NSMutableURLRequest: 0x124fdddc0> { URL: https://graph.windows.net/company.onmicrosoft.com/drive/items/root/children } I am wondering what is incorrect in the request. Could someone help me to sort this out?

    opened by rdv0011 20
  • Name conflict error during uploading file

    Name conflict error during uploading file

    We're using the ios sdk to upload files. It works fine for a new file. but if we try to upload the same file again, the sdk will return a 409 error as follows: Error Domain=com.microsoft.onedrive.errors Code=409 "conflict" UserInfo={error= nameAlreadyExists : An item with the same name already exists under the parent, NSLocalizedDescription=conflict}

    Here is the request we are using to upload the file to our app folder :

    [[[[[[self.client drive] special:@"approot"] itemByPath:name] contentRequest] nameConflict:[ODNameConflict replace] ] uploadFromFile: [NSURL fileURLWithPath:path] completion:^(ODItem *response, NSError *error) { if (error == nil) { } else { NSLog(@"one drive upload:%@", error); } } ];

    bug 
    opened by kmtbang 13
  • Chunked Upload Support

    Chunked Upload Support

    I created a temp file (creates file of size 107Mb): mkfile -n 107m 1.rar

    I try to upload it and it works but in the completion block I always get a random error. Examples of errors: ...2.rar, error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

    OneDrive SDK ERROR : Error from download response Error Domain=com.microsoft.onedrive.errors Code=413 "request too large" UserInfo={NSLocalizedDescription=request too large}

    enhancement 
    opened by gerchicov-bp 12
  • Get Progress without KVO

    Get Progress without KVO

    Is there anyway to get upload progress without KVO? I am getting weird behavior when the app stays in the background too long. I remove the observer before I deallocate, but that doesn't seem to help. Closing the app and reopening fixes that issue.

    question 
    opened by ghost 11
  • Progress not working with mime type

    Progress not working with mime type "application/octet-stream"

    Thanks for the fix for #3. Unfortunately I still have an issue with getting the actual progress. Downloading files of MIME type application/octet-stream and showing its progress doesn't seem to work.

    Here is a shortened output log of the NSProgress object while downloading a ~2 MB file.

    2015-09-05 21:59:33.249 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 0 of -1  
    2015-09-05 21:59:33.250 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 1043 of -1  
    2015-09-05 21:59:33.252 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 8192 of -1  
    2015-09-05 21:59:33.254 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 6040 of -1  
    2015-09-05 21:59:33.257 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 8187 of -1  
    2015-09-05 21:59:33.272 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 8192 of -1  
    2015-09-05 21:59:33.275 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 8187 of -1  
    2015-09-05 21:59:33.278 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 8192 of -1  
    2015-09-05 21:59:33.281 [...] <NSProgress: 0x7f843c547790> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 8187 of -1  
    
    ...
    

    As you can see totalUnitCount (or expectedBytes) is always -1. Furthermore completedUnitCount (or sentBytes) isn't accumulating, not sure if this works out for other file types as well that are not affected by this bug.

    Any idea how to solve this? I have this bad feeling that it has to be fixed at the backend, because this progress delegate is called by NSURLSession (in ODURLSessionManager) and it relies on Content-Length being set.

    bug 
    opened by tobihagemann 11
  • OneDrive for Business: wrong address of serviceEndpointUri and serviceResourceId

    OneDrive for Business: wrong address of serviceEndpointUri and serviceResourceId

    Hi all, In our app we integrate a lot of external sources, among them OneDrive.

    We are integrated with OneDrive (before SkyDrive) since a couple of years. Last year, as it was asked by our users to support ODfB, we changed the SDK into OneDrive SDK (from CocoaPods, interference was the pod ADALiOS). It worked well.

    However, since last month this integration stopped to work. Please see below detailed information.

    Currently during log in to ODfB account, we get error:

    “There was a problem logging you in. Could not discover the api endpoint for the given user. Make sure you have correctly enabled the SharePoint files permissions in Azure portal." Error code: 1

    The Access settings should be correct, we set these with this instructions: https://dev.onedrive.com/app-registration.htm#3-register-your-app-with-azure-active-directory

    We have a problem with getting the correct address of resources URL https://dev.onedrive.com/auth/aad_oauth.htm#step-3-discover-the-onedrive-for-business-resource-uri

    When we send request for services: https://api.office.com/discovery/v2.0/me/services in response we get only capability of Directory, and not like in documentation: MyFiles.

    {
        "@odata.context" = "https://api.office.com/discovery/v2.0/me/$metadata#allServices";
        value =     (
                    {
                "@odata.editLink" = "services('Directory@[email protected]')";
                "@odata.id" = "https://api.office.com/discovery/v2.0/me/services('Directory@[email protected]')";
                "@odata.type" = "#Microsoft.DiscoveryServices.ServiceInfo";
                capability = Directory;
                entityKey = "Directory@[email protected]";
                providerId = "…";
                providerName = Microsoft;
                serviceAccountType = 2;
                serviceApiVersion = "v1.0";
                serviceEndpointUri = "https://graph.windows.net/miknobuisness.onmicrosoft.com/";
                serviceId = AZURE;
                serviceName = "Microsoft Azure";
                serviceResourceId = "https://graph.windows.net/";
            }
        );
    }
    

    When we request other rest: allServices, the response has more descriptions: https://api.office.com/discovery/v2.0/me/allServices

    {
        "@odata.context" = "https://api.office.com/discovery/v2.0/me/$metadata#allServices";
        value =     (
                    {
                "@odata.editLink" = "allservices('Directory@AZURE')";
                "@odata.id" = "https://api.office.com/discovery/v2.0/me/allservices('Directory@AZURE')";
                "@odata.type" = "#Microsoft.DiscoveryServices.ServiceInfo";
                capability = Directory;
                entityKey = "Directory@AZURE";
                providerId = "72f988bf-86f1-41af-91ab-2d7cd011db47";
                providerName = Microsoft;
                serviceAccountType = 2;
                serviceApiVersion = "";
                serviceEndpointUri = "http://azure.microsoft.com/";
                serviceId = AZURE;
                serviceName = "Microsoft Azure";
                serviceResourceId = "<null>";
    },
    {…},
    {
                "@odata.editLink" = "allservices('MyFiles@O365_SHAREPOINT')";
                "@odata.id" = "https://api.office.com/discovery/v2.0/me/allservices('MyFiles@O365_SHAREPOINT')";
                "@odata.type" = "#Microsoft.DiscoveryServices.ServiceInfo";
                capability = MyFiles;
                entityKey = "MyFiles@O365_SHAREPOINT";
                providerId = "72f988bf-86f1-41af-91ab-2d7cd011db47";
                providerName = Microsoft;
                serviceAccountType = 2;
                serviceApiVersion = "";
                serviceEndpointUri = "http://www.microsoft.com/en-us/office365/online-software.aspx";
                serviceId = "O365_SHAREPOINT";
                serviceName = "Office 365 SharePoint";
                serviceResourceId = "<null>";
    }
    

    In documentation is info about we should get address of serviceEndpointUri and serviceResourceId, but they are wrong.

    Can you help us please?

    opened by trzeciak 10
  • Remote items and shared folders

    Remote items and shared folders

    It seems to me that this SDK doesn't take remote items and shared folders into account, as it should do: https://dev.onedrive.com/misc/working-with-links.htm

    I came across this issue, because ODItem's folder property is nil for shared folders. It would be great if this SDK would handle shared folders properly. I'll implement on a workaround for my project in the meantime.

    Edit: Maybe some further information for reproducing... share a folder from a second account to your first account... that's it! That means, you can't be the owner of the shared folder. If you're the owner of the shared folder, everything's just fine. The other way round causes the issue.

    enhancement service issue 
    opened by tobihagemann 9
  • ODClient.loadCurrentClient() can get to a state where it can never load the current client.

    ODClient.loadCurrentClient() can get to a state where it can never load the current client.

    Repro step:

    • Sign in using MSA.
    • Test to see if you can get ODClient.loadCurrentClient() simply by just calling it. (Good)
    • Kill the app/re-start the app.
    • Attempt to refresh the token or call anything that triggers “storeAccount” in ODAccountStore such as making the token expires so that it will automatically refreshes the token.
    • Kill the app/re-start the app
    • You can no longer access ODClient.loadCurrentClient()
    • Now it gets into an unrecoverable state.

    Reason:

    The OneDriveSDK upon sign in does this:

    Sign in:

    • Get a response back , parse and store the tokens and userId (where userId is lowercase) in the keychain.
    • There is a map of accountId:serviceInfo (accountId is case sensitive) that gets stored in a file via NSKeyedArchiver.
    • There is a field called “currentSession” which is also the accountId (case sensitive) gets stored in a file via NSKeyedArchiver
    • When you call ODClient.loadCurrentClient(), everything works as expected because all of the sessions are still in memory.

    What happens when we kill and relaunch the app and attempt to access the current client?

    • It calls loadAllAccounts, which deserialize the ‘currentSession’ and the ‘accountId:serviceInfo' map into memory. Because both of the currentSession and accountId stored in the map are case-sensitive , the look up will succeed. We can find all of the account information associate with this session.
    • It then loads all of the secured information from keychain.
    • The problem here occurs when the code attempts to assign the “currentSession" to the session we found in the keychain. The session’s account id is now LOWERCASE

    IF NOTHING triggers “storeAccounts”, then everything will work fine because nothing new gets saved. However, since the OneDriveSDK supports automatic refreshing token, upon succeeding the refresh, it will call ‘storeAccounts’ , and rewrite the “currentSession” to a file in lowercase. The next time the application loads, it will not be able to find a matching account information due to case-mismatch.

    We can no longer call ODClient.loadCurrentClient()

    bug 
    opened by friedtofu 9
  • App folder children request returns empty array

    App folder children request returns empty array

    I'm using the iOS SDK to authenticate with a "onedrive.appfolder" scope and query/download files within the application folder.

    The request below works as expected:

    [[[[self.odClient drive] special:@"approot"] request] getWithCompletion:^(ODItem *response, NSError *error) {
      NSLog (@"response: %@", response);
    }];
    

    However when I modify it to fetch the children items instead, the response received is an empty array:

    [[[[[self.odClient drive] special:@"approot"] children] request] getWithCompletion:^(ODCollection *response, ODChildrenCollectionRequest *nextRequest, NSError *error) {
      NSLog (@"response: %@", [response value]);
    }];
    

    If I try and fetch the items using an explicit path to the Apps folder, it works as expected and the array returned contains all 3 items within the app's folder.

    [[[[[self.odClient root] itemByPath:@"Apps/[APP_NAME_REDACTED]"] children] request] getWithCompletion:^(ODCollection *response, ODChildrenCollectionRequest *nextRequest, NSError *error) {
        NSLog (@"response: %@", [response value]);
    }
    

    Is this a bug or am I doing something wrong? Thanks, Rog

    bug 
    opened by rpassis 8
  • iOS. authenticatedClientWithCompletion fails with error

    iOS. authenticatedClientWithCompletion fails with error "Cannot add a new item in the keychain. Error code: -25243"

    When I call the function authenticatedClientWithCompletion in order to log in with OneDrive for Business account it fails with the following errors:

    1. Cannot add a new item in the keychain. Error code: -25243
    2. Failed to login OneDrive with error: Error Domain=com.microsoft.onedrivesdk.autherror Code=1 "There was a problem logging you in" UserInfo={ODAuthErrorKey=Could not discover the api endpoint for the given user. Make sure you have correctly enabled the SharePoint files permissions in Azure portal., NSLocalizedDescription=There was a problem logging you in}

    Could please suggest a solution?

    bug 
    opened by rdv0011 7
  • Can't Sign in with MS account

    Can't Sign in with MS account

    1. When I create new App on https://portal.azure.com, I also configurate Redirect URL for IOS platform like this: 'msauth.com.abc.apps.xyz://auth'
    2. AppDelegate: ODClient.setMicrosoftAccountAppId("cc07b813-1749-4745-88cf-1e9e0fb183b3", scopes: ["onedrive.readwrite", "offline_access"])
    3. call:
      ODClient.client { (client, error) in guard error != nil else { return } }
    4. Error when open MS sign in view controller: "invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application. onedrive sdk"
    5. more infor: when i try with AppID(ClientID: '0000000048160AF8' or another my old app: ) from the sample: https://github.com/OneDrive/onedrive-sdk-ios/tree/master/Examples/iOSExplorer -> no problem
    opened by nguyenvietvu 2
  • Urgent :: Use of deprecated ADAL version

    Urgent :: Use of deprecated ADAL version

    Apple does not accept iOS apps which using the deprecated UIWebView anymore.

    Currently, onedrive-sdk-ios is only working with the long time deprecated ADAL version 1.2. This version of ADAL is using UIWebView. Please update onedrive-sdk-ios to use the lates ADAL version which is using WKWebViews.

    Compiler warning: Pods/ADAL/ADALiOS/ADALiOS/ADAL_iPad_Storyboard.storyboard:s1f-g9-Kf9: warning: UIWebView is deprecated since iOS 12.0 [7]

    /Pods/ADAL/ADALiOS/ADALiOS/ADAL_iPhone_Storyboard.storyboard:aQj-zZ-Grp: warning: UIWebView is deprecated since iOS 12.0 [7]

    opened by moerschl 11
  • One Drive Login PresentContrller iOS13

    One Drive Login PresentContrller iOS13

    when calling (ODClient authenticatedClientWithCompletion) in iOS 13. The present controller appears for login but the user can dismiss it using gesture as per iOS 13. When the user does not use the cancel button the delegate not being called and progress hud disappear after request time out.

    opened by usman1372 0
Releases(1.1.2)
Owner
OneDrive
Official projects and SDKs for Microsoft OneDrive
OneDrive
Px-mobile-sdk-demo-app - PerimeterX Mobile SDK - Demo App

About PerimeterX PerimeterX is the leading provider of application security solu

PerimeterX 1 Nov 20, 2022
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter 45 Nov 29, 2022
Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK

RadarCOVID iOS App Introduction Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK Prerequisites These are the tools used to bu

Radar COVID 146 Nov 24, 2022
TelegramStickersImport — Telegram stickers importing SDK for iOS

TelegramStickersImport — Telegram stickers importing SDK for iOS TelegramStickersImport helps your users import third-party programaticaly created sti

null 35 Oct 26, 2022
Muxer used on top of Feed iOS SDK for airplay

FeedAirplayMuxer Muxer used on top of Feed iOS SDK for airplay purposes. Demo Project --> https://github.com/feedfm/AirplayDemo Feed Airplay Muxer is

Feed Media 0 May 6, 2022
Basispay IOS SDK Version 2

BasisPay-IOS-KIT BasisPay IOS Payment Gateway kit for developers INTRODUCTION This document describes the steps for integrating Basispay online paymen

null 0 Oct 21, 2021
Release repo for Gini Bank SDK for iOS

Gini Bank SDK for iOS The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips. By integra

Gini GmbH 1 Dec 6, 2022
Da Xue Zhang Platform Lvb iOS SDK

Cloud_Lvb_SDK iOS API Reference Dxz Meeting iOS SDK是为 iOS 平台用户音视频服务的开源 SDK。通过大学长开放平台自研RTC,RTM系统,为客户提供质量可靠的音视频服务。 类 类名 描述 CLS_PlatformManager SDK的音视频主要

null 8 Jan 10, 2022
PayPal iOS SDK

PayPal iOS SDK Welcome to PayPal's iOS SDK. This library will help you accept card, PayPal, Venmo, and alternative payment methods in your iOS app. Su

PayPal 25 Dec 14, 2022
Unofficial Notion API SDK for iOS & macOS

NotionSwift Unofficial Notion SDK for iOS & macOS. This is still work in progress version, the module interface might change. API Documentation This l

Wojciech Chojnacki 59 Jan 8, 2023
150,000+ stickers API & SDK for iOS Apps.

English | 한국어 Stipop UI SDK for iOS Stipop SDK provides over 150,000 .png and .gif stickers that can be easily integrated into mobile app chats, comme

Stipop, Inc. 19 Dec 20, 2022
Spotify SDK for iOS

Spotify iOS SDK Overview The Spotify iOS framework allows your application to interact with the Spotify app running in the background on a user's devi

Spotify 522 Jan 6, 2023
Headless iOS/Mac SDK for saving stuff to Pocket.

This SDK is deprecated Howdy all! ?? Thanks for checking out this repo. Your ?? mean a lot to us. ?? Unfortunately, this project is deprecated, and th

Pocket 230 Mar 18, 2022
Evernote Cloud SDK for iOS

Evernote Cloud SDK 3.0 for iOS This is the official Evernote SDK for iOS. To get started, follow the instructions bellow. Additional information can b

Evernote 256 Oct 6, 2022
iOS SDK for the Box Content API

Box iOS SDK Getting Started Docs: https://developer.box.com/guides/mobile/ios/quick-start/ NOTE: The Box iOS SDK in Objective-C (prior to v3.0.0) has

Box 112 Dec 19, 2022
Stripe iOS SDK

Stripe iOS SDK The Stripe iOS SDK makes it quick and easy to build an excellent payment experience in your iOS app. We provide powerful and customizab

Stripe 1.8k Jan 5, 2023
AWS SDK for iOS. For more information, see our web site:

AWS SDK for iOS The AWS SDK for iOS provides a library and documentation for developers to build connected mobile applications using AWS. Features / A

AWS Amplify 1.6k Dec 26, 2022
Zendesk Mobile SDK for iOS

⚠️ This Repository has been deprecated, please go to here for the Zendesk Support SDK ⚠️ Zendesk Mobile SDK for iOS Zendesk SDK for mobile is a quick,

Zendesk 113 Dec 24, 2022
PlayKit: Kaltura Player SDK for iOS

Kaltura Player SDK Demo: Demo repo. If you are a Kaltura customer, please contact your Kaltura Customer Success Manager to help facilitate use of this

Kaltura 77 Jan 3, 2023