Coder Social home page Coder Social logo

onedrive-sdk-ios's Introduction

Note: OneDrive SDK for iOS to be deprecated / archived, please use Microsoft Graph SDKs instead

What is happening?

As of March 10, 2022 the OneDrive SDK for iOS is beginning the process of being deprecated and ultimately the project archived.

Why is this happening?

There are several reasons why we are choosing to end support for this SDK. Most importantly in the time since this SDK was last updated we have seen the emergence of Microsoft Graph as the preferred path for interfacing with OneDrive programmatically. Microsoft Graph receives the latest and greatest updates and provides more up-to-date SDKs as well.

Additionally the OneDrive SDK for iOS currently uses the UIWebView component that has been marked deprecated by Apple. Although no current deadline for updating applications has been provided (see article) we expect this functionality to stop working at some point in an iOS update.

How do I make the transition to Microsoft Graph?

To get started with Microsoft Graph on iOS please use the following resources:

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.

onedrive-sdk-ios's People

Contributors

aclev avatar chaseholland avatar gigades avatar jeremykelley avatar kevklam avatar kreuli avatar mimisasouvanh avatar nazywamsiepawel avatar paweldudek avatar rgregg avatar sameerklt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onedrive-sdk-ios's Issues

Search API is returning 0 results for Business User

Search API is working well with personal account. But for business user (account type : ODADAccount) it always returning 0 results lately.

Note: There few files with name "abc"
Code:
NSString *itemId = @"root";
ODItemSearchRequest *req = [[[self.client.drive items:itemId] searchWithQ:@"abc"] request];
[req executeWithCompletion:^(ODCollection *response, ODItemSearchRequest *nextRequest, NSError *error) {
}];

Support for tvOS requested

It would be great to use this Pod in a tvOS project. Is this new platform as a new target on your roadmap?

Pod error

Getting problem on share url of file

If we send create link request, getting error on response

ODItemCreateLinkRequest *createLinkRequest = [[ODItemCreateLinkRequest alloc] initWithType:@"view" URL:[NSURL URLWithString:item.webUrl] options:nil client:odclient];

[createLinkRequest executeWithCompletion:^(ODPermission response, NSError error) {
NSLog(@"print : %@",response.link);
NSLog(@"eroororo%@",error);
}];

Result :
OneDrive SDK ERROR : Error from data task : 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.}

Library not found for -lADALiOS

I download the project,and open the project in Examples(iOSExplorer),and pod install,but Xcode still :"Library not found for -lADALiOS". Did I miss some steps? Xcode Version 6.3.1

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.

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?

OneDrive for Business - App folder name uses clientId instead of app name

Hi all,

Not sure if this is an iOS SDK related issue but I thought I'd post it here in the hope that someone might be able to point me in the right direction.

We have an application that integrates seamlessly with OneDrive Personal accounts, and have started making changes to cater for OneDrive for Business accounts as well.

Syncing works as expected however we are experiencing an issue where the first call to [[[self.odClient drive] special:@"approot"] children] creates a folder called "Apps/My app name" when using OD Personal accounts.

However, the same call on OneDrive Business accounts creates a folder using the registered application's client ID instead of its name i.e. "Apps/12345-6789-1234-abcd-efghjklmxyz"

The URL generated for the request above is https://mydomain.sharepoint.com/_api/v2.0/me/drive/special/approot/children which looks correct.

The app settings on ActiveDirectory seem correct i.e. the app name is "My app name".

Any ideas of why this might be happening?

Many thanks in advance.
Rog

Storyboard missing in iOSExplorer!

Xcode: 7.0.1

I'm having the following error when build:

/Users/shadow/Downloads/onedrive-sdk-ios-master/OneDriveSDK/Pods/ADALiOS/ADALiOS/ADALiOS/ADAL_iPad_Storyboard.storyboard: Interface Builder could not open the document ADAL_iPad_Storyboard.storyboard" because it does not exist.

I can see two .storyboard files are at Pods/ADALiOS/Resources, though. How should I fix this?

OneDrive for Business: first login attempt after entering wrong password fails

The following issue happens when using the OneDrive SDK for iOS (version 1.1.2) in my own iOS app but the same behaviour can be seen with the OneDrive app from the App Store (version 6.13.3):

  • Start to sign in to OneDrive for Business by entering a OneDrive for Business email address.
  • In the upcoming screen, enter a wrong password -> login is rejected (correct).
  • Enter a wrong password again -> login is rejected again (correct).
  • Enter the correct password -> login is rejected! (BUG)
  • Enter the correct password again -> login is granted (correct).

So the bug is that the correct password is not accepted at the first time after entering a wrong password.

Generate shared link to file

How would one go about generating a shared link to an uploaded file? A link that does not expire and can be opened by other people

Unable to get user details and upload file

Hi,

I'm able to authenticate user. But after authentication I want user's primary details. I didn't found any method or parameters of this SDK, through which I can get the details. Current scope is

"wl.signin", "wl.offline_access", "onedrive.readonly", "onedrive.readwrite", "onedrive.appfolder"

Also, when I'm trying to upload file, I'm getting below error

OneDrive SDK ERROR : Error from download response Error Domain=com.microsoft.onedrive.errors Code=405 "method not allowed" UserInfo=0x17f5f000 {NSLocalizedDescription=method not allowed, error= invalidRequest : Item does not match expected type}

I'm using below method:

let request = odClient.drive().items(folderId).contentRequest()
let urlPath = NSURL(string: strPath!)
request.uploadFromFile(urlPath) { (item, error) -> Void in
     if(error == nil){
          print("Successfully uploaded")
     }
 }

I din't found any help over internet related to this issue. Please guide me

Upload file with cyrillic return 400 error

I try to upload files throught call:
[ [ [ [ client root ] itemByPath:@"Д.jpg" ] contentRequest ] uploadFromFile:[ NSURL fileURLWithPath:from ] completion:^(ODItem * item, NSError * error) { NSLog(@"%@", error); } ];

When I try upload new file with name "Д.jpg", it return 400 error. Error disappears, if I change name to "Ф.jpg" or any other.

Strange problem. I use cocoapods.

ODURLSessionDownloadTask not reporting progress correctly

Hi,

I've been trying to get progress info from OneDrive upload and download tasks. For the upload it is working fine. The download task however returns a NSProgress object that always reports "fractionCompleted" as 0.0. This happens even if the file is actually downloaded without errors.
Is this something known?

Thanks!

Build Failed On Case-Sensitive System

Hi ,

I use cocoapod to integrate this SDK in our app, but it seems there are some error when building it.

/%OURPROJECTPATH%/Pods/OneDriveSDK/OneDriveSDK/OneDriveCoreSDK/model/ODAsyncOperationStatus.h:24:9: 'UIKit/UiKit.h' file not found

and I just search & replaced the string 'UIKit/UiKit.h' with 'UIKit/UIKit.h' in all files of this SDK , there will be no error and run successfully in our project. but this modification will be reset when I update it from remote, so I can't use this SDK as a pod dependency target in my customize pod.
It seems like there is a spelling-mistake of UiKit.h from U"I"Kit.h, this error will lead to build failed when using case-sensitive system.

Could not build module 'OneDriveSDK'

Hi! I've installed the OneDriveSDK via cocoaPods using 'pod 'OneDriveSDK''.
However, i can't compile my project because it cannot build the OneDriveSDK.
The reason is that in the file: ODBusinessAuthProvider.h I get this error:

.../Pods/OneDriveSDK/OneDriveSDK/Auth/ODBusinessAuthProvider.h:23:9: 'ADAuthenticationContext.h' file not found

What should be the problem?

How to cancel the previous request ?

[childrenRequests getWithCompletion:^(ODCollection *response, ODChildrenCollectionRequest *nextRequest, NSError *error){
if (!error){
}
if(nextRequest)
{
[self loadChildrenWithRequest:nextRequest]; //here
}

if i have many files in a directory, nextRequest will call [self loadChildrenWithRequest:nextRequest] until we receive all the files. Before the iteration get complete, If i click some other directory, then previous directory files and currently clicked directory files are merged in result. Is there any way to cancel previous request @aclev

Incorrect Date formatter

The date's found in the dictionary defining an ODItem dates do not match what the NSDateFormatters used in NSDate+ODSerialization.h.

The current date strings look like
2015-11-02T21:09:32Z
and the formatter is looking for
yyyy-MM-dd'T'HH:mm:ss.SSSZ
it should just be
yyyy-MM-dd'T'HH:mm:ssZ

Login screen always pops up for live accounts

Hi there,
I am trying to create a simple app that does both live accounts and office accounts.
At the moment, when i log in using live accounts, it logs in but when i start the app, the information is not saved - thus new log in screen pops up every time.

This also happens in the included explorer.

It seems like the pod pulls the older version of the ADALiOS, is this intended?

Thanks

Login site not being localized after language change in the iOS settings

It looks like the language being used on App install is cached by the SDK in some way, because if I change the system language in the iOS settings and then in my App try to login to OneDrive again the login site is shown in the first language used while installing the App. After reinstalling the app the login site is shown in the right language.

Tested on ipad3 iOS8 and ipad mini iOS9

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.

Cannot login using iOS 9

After calling authenticatedClientWithCompletion: and entering email address, I get redirected to a blank screen (within the login popover). I can successfully login using the same code with iOS 8.

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()

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?

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?

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

Disable or Remove 'Create Account' option from one drive authentication page

I am trying to integrate onedrive for my ios app. I am using onedrive ios sdk for that. I am calling ODClient.authenticatedClientWithCompletion for launching authentication screen. This does launch authentication screen, and I am able to login. However in the authentication screen, both Sign In and 'No Account? Create One' option is visible. According to apple guideline an app will be rejected, if its integration point has create account option, as its violates their policy. This is the reason why dropbox, google drive sdk's for ios, does not have create account option. Is there a way by which I can disable or remove 'Create Account' option from one drive authentication screen.

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);
}
}
];

Lacking an example of resumable item upload

According to the API reference, one should use resumable item upload when the size is larger than 100MB, but the current sample app lacks it. Will it be added in the future?

Can't be used with OneDrive business accounts

After logging in with a OneDrive business, making any request results in an assert failure in ODRequestBuilder initWithURL. Here's the callstack when used with the example explorer app.

2015-11-23 12:07:52.297 iOSExplorer[72640:1748960] *** Assertion failure in -[ODDriveRequestBuilder initWithURL:client:], /Users/tkr/Downloads/onedrive-sdk-ios/OneDriveSDK/OneDriveCoreSDK/Core/ODRequestBuilder.m:29
2015-11-23 12:07:52.304 iOSExplorer[72640:1748960] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: url'
*** First throw call stack:
(
0 CoreFoundation 0x000000010aceef45 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010a768deb objc_exception_throw + 48
2 CoreFoundation 0x000000010aceedaa +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010a3b55ee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 iOSExplorer 0x000000010a1931f3 -[ODRequestBuilder initWithURL:client:] + 323
5 iOSExplorer 0x000000010a176118 -[ODClient(HelperMethods) drive] + 136
6 iOSExplorer 0x000000010a11c779 -[ODXItemCollectionViewController loadChildren] + 297
7 iOSExplorer 0x000000010a11bebf __47-[ODXItemCollectionViewController signInAction]_block_invoke + 143
8 iOSExplorer 0x000000010a17265f __72+[ODClient(Authentication) authenticatedClientWithAppConfig:completion:]_block_invoke + 95
9 iOSExplorer 0x000000010a173d22 -[ODClient(Authentication) onAuthenticationCompletionWithError:authProvider:httpProvider:completion:] + 338
10 iOSExplorer 0x000000010a172fdb __103-[ODClient(Authentication) authenticateWithAuthProvider:httpProvider:logger:viewController:completion:]_block_invoke + 91
11 iOSExplorer 0x000000010a16e0ea __68-[ODBusinessAuthProvider authenticateWithViewController:completion:]_block_invoke_3 + 298
12 iOSExplorer 0x000000010a133c88 __145-[ADAuthenticationContext internalAcquireTokenByRefreshToken:clientId:resource:userId:cacheItem:validateAuthority:correlationId:completionBlock:]_block_invoke_2 + 552
13 iOSExplorer 0x000000010a13986f __125-[ADAuthenticationContext request:requestData:requestCorrelationId:isHandlingPKeyAuthChallenge:additionalHeaders:completion:]_block_invoke + 3151
14 iOSExplorer 0x000000010a156113 -[ADWebRequest completeWithError:andResponse:] + 323
15 iOSExplorer 0x000000010a156d70 -[ADWebRequest connectionDidFinishLoading:] + 432
16 CFNetwork 0x000000010cde19ae __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69
17 Foundation 0x000000010a3dd3b8 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK
+ 7
18 Foundation 0x000000010a3190e5 -[NSBlockOperation main] + 101
19 Foundation 0x000000010a2fc036 -[__NSOperationInternal _start:] + 646
20 Foundation 0x000000010a2fbc47 __NSOQSchedule_f + 194
21 libdispatch.dylib 0x000000010d3de49b _dispatch_client_callout + 8
22 libdispatch.dylib 0x000000010d3c48ec _dispatch_queue_drain + 2215
23 libdispatch.dylib 0x000000010d3c3e0d _dispatch_queue_invoke + 601
24 libdispatch.dylib 0x000000010d3c6a56 _dispatch_root_queue_drain + 1420
25 libdispatch.dylib 0x000000010d3c64c5 _dispatch_worker_thread3 + 111
26 libsystem_pthread.dylib 0x000000010d70f4f2 _pthread_wqthread + 1129
27 libsystem_pthread.dylib 0x000000010d70d375 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Search API Query parameter doesn't have OR operator ?

I was using Search API to fetch files. I wanted fetch specific type of files and get children API is time consuming and I have to recursively crawl through the folders.

Anything I can use to query such as query = 'abc OR xyz' which would return me filename, metadata, and file content having 'abc' or 'xyz'. As I currently this is not possible for now.

Thanks

Onedrive for Business - Cannot share file/folder: 403 “forbidden”

I setup one iOS app in Azure Portal to integrate with OneDrive for business.

In "Permission to other app" we selected all permission for - Microsoft Graph - Office 365 sharepoint online - Window Azure Active Directory

I run iOS sample code in SDK and it works for almost functions accept for "Share file". Error: 403 "forbidden" UserInfo={error=notAllowed: The feature has been disabled. Please contact your admin to get it enable., NSLocalizedDescription=forbidden}

Maybe I missed any configuration somewhere? Could you please advice

Thanks & Regards,

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?

Unable to upload audio file

I tried to upload an m4a or mp3 file with the following code.

NSURL *fileURL = xxxx;
ODItemContentRequest *request = [[[[ODClient loadCurrentClient] drive] items:path] contentRequest];
self.task = [request uploadFromFile:fileURL completion:^(ODItem *item, NSError *error)

Then there is always return an error "unsupported media type" UserInfo=0x7f7fb5172210 {error= : The request entity's media type 'application/octet-stream' is not supported for this resource."

I know it probably the content type is wrong. But I have no idea how to fix this, since I have no way to get the NSMutableURLRequest created from your library.

Many thanks.

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.

App is not authenticating for business accounts

Hi Team,

I am using this sdk to integrate my app with onedrive cloud.
I created the appId from Application Portal.

I am using the below code snippet for authenticating and login from my app.
[ODClient setMicrosoftAccountAppId:@"xxxx-xxx-xxx-xxxx-xxxxxx" scopes:@[@"onedrive.readwrite"] ]; [ODClient setActiveDirectoryAppId:@"xxxx-xxx-xxx-xxxx-xxxxxx" redirectURL:@"urn:ietf:wg:oauth:2.0:oob" flags:@{@"NoThumbnails" : @(YES)}];

I am unable to login with my business account or personal account. I am getting the below error as response,
Error raised: 15. Additional Information: Domain: ADAuthenticationErrorDomain ProtocolCode:unauthorized_client Details:AADSTS7xxxxx: Application 'xxxx-xxx-xxx-xxxx-xxxxxx' is not supported for this API version.

Any one can help me with this? Thanks in advance

[ODClient authenticatedClientWithCompletion:] never calls completion handler

Hi,

We've developed an app which integrates the OneDrive SDK and a customer is experiencing a problem logging in. I am not personally able to reproduce the issue, as the app works correctly on my machine. However, the customer reports that they are presented with the login screen, they enter their credentials, grant our app access to their OneDrive, but then after the login screen closes, nothing happens. There is no error message nor any status update, which would indicate that our app's completion handler is never called.

If it's relevant, the user says he was presented with an option to choose between OneDrive and OneDrive for Business, but states that he does not have a OneDrive for Business account. My company has tested the app with multiple accounts of our own (both OneDrive and OneDrive for Business) and have not experienced any problems. Is there any known reason why the SDK would fail to call the completion handler, and if so, what should we do about it?

duplicate symbol problem

I have followed the instruction to install pods. One question: Add the following to your Podfile : pod 'OneDriveSDK' => it means append pod 'OneDriveSDK' to the line of the file ?

When I open OneDriveSDK.xcodeproj and start build, it shows the following errors:

duplicate symbol OBJC_CLASS$_ODAADAccountBridge in:
/Users/xxxxxxx/Library/Developer/Xcode/DerivedData/OneDriveSDK-acgkcrgmhevkjlgmfsreytxbrcqw/Build/Intermediates/OneDriveSDK.build/Debug-iphoneos/OneDriveSDK.build/Objects-normal/arm64/ODAADAccountBridge.o
/Users/xxxxxxx/Library/Developer/Xcode/DerivedData/OneDriveSDK-acgkcrgmhevkjlgmfsreytxbrcqw/Build/Products/Debug-iphoneos/libOneDriveSDK.a(ODAADAccountBridge.o)
duplicate symbol OBJC_METACLASS$_ODAADAccountBridge in:
/Users/xxxxxxx/Library/Developer/Xcode/DerivedData/OneDriveSDK-acgkcrgmhevkjlgmfsreytxbrcqw/Build/Intermediates/OneDriveSDK.build/Debug-iphoneos/OneDriveSDK.build/Objects-normal/arm64/ODAADAccountBridge.o
/Users/xxxxxxx/Library/Developer/Xcode/DerivedData/OneDriveSDK-acgkcrgmhevkjlgmfsreytxbrcqw/Build/Products/Debug-iphoneos/libOneDriveSDK.a(ODAADAccountBridge.o)
duplicate symbol OBJC_CLASS$_ODAADServiceInfo in:
/Users/xxxxxxx/Library/Developer/Xcode/DerivedData/OneDriveSDK-acgkcrgmhevkjlgmfsreytxbrcqw/Build/Intermediates/OneDriveSDK.build/Debug-iphoneos/OneDriveSDK.build/Objects-normal/arm64/ODAADServiceInfo.o
/Users/xxxxxxx/Library/Developer/Xcode/DerivedData/OneDriveSDK-acgkcrgmhevkjlgmfsreytxbrcqw/Build/Products/Debug-iphoneos/libOneDriveSDK.a(ODAADServiceInfo.o)

ld: 400 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I cannot compile the project.

Xcode Archive Project Problem

I have added OneDriveSDK project to my app project. When I deploy my app to the device, it shows:

dyld: Library not loaded: ...../OneDriveSDK
Reason: image not found

Then I need to add OneDriveSDK.framework to embedded libraries. This problem is solved.

However, it causes another issue: after archiving project, OneDriveSDK.framework is attached to my app. OneDriveSDK.framework is "explicitly" shown in the dialog when I tried to upload my app to app store. It supposed not to exist.

Of course, remove OneDriveSDK.framework from embedded libraries, the problem will be solved. However, it returns to my first problem: I cannot deploy app to the device.

Any solutions?

testAccountSessionWithValidResponseAndRefreshToken fails due to a bad time evaulation

-ODAuthHelperTests testAccountSessionWithValidResponseAndRefreshToken

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
/Users/travis/build/OneDrive/onedrive-sdk-ios/OneDriveSDK/OneDriveSDKTests/AuthTests/ODAuthHelperTests.m:71: ((dateTimeString) equal to (expiresDateString)) failed: ("9/21/15, 10:17:04 PM GMT") is not equal to ("9/21/15, 10:17:05 PM GMT"):

XCTAssertEqualObjects(session.accountId, responseDictionary[OD_AUTH_USER_ID]);

XCTAssertNotNil(session.expires);

NSString *expiresDateString = [NSDateFormatter localizedStringFromDate:session.expires dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterFullStyle];

XCTAssertEqualObjects(dateTimeString, expiresDateString);

Item copying does not report progress and is holding completion handler indefinitely

According to the documentation of how to perform item copying, https://github.com/OneDrive/onedrive-sdk-ios/blob/master/docs/items.md, we should be able to monitor the progress property of the returned task. However, it reported either 0 or 1 when I was copying a folder with 3 files inside (a total of 4 items). status.percentageCompleted in the completion handler doesn't help too (either 0 or 1). status.status does report something verbally (like completed 2/4; x of y bytes)

Also as the title says, the completion handler is getting retained indefinitely thus it might be leaking memory

As the doc also says, the handler will be called whenever there is an update, is naming the method executeWithCompletion: misleading?

Unable to access progress object

I would like to show the user some progress while downloading/uploading. To my understanding ODURLSessionDownloadTask and ODURLSessionUploadTask are subclasses of ODURLSessionProgressTask that should contain a NSProgress object. But this is always nil.

I've already dug through the code, but I just don't understand the progress concept of this project. Maybe it's because I'm not that familiar with NSProgress. I can't get my head around this whole "reference to a progress object" and "_innerProgress".

Am I missing something? How is this supposed to work? Thanks!

Error using Azure Active Directory

When I use Azure Active Directory (with application permission to have all SharePoint Online permissions) and do
[ODClient setActiveDirectoryAppId:@"XXXX" scopes:@[@"wl.signin",@"onedrive.readwrite", @"onedrive.appfolder"] redirectURL:@"https://specifiedredirect"];

it signs me in using Office 365 account, and the log in information is not required for each restart of the app.
However, it fails in getting the drive with the following message

OneDrive SDK ERROR : Error from data task : Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSUnderlyingError=0x7fc1a2412740 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}, NSErrorFailingURLStringKey=_api/v2.0/me/drive/, NSErrorFailingURLKey=_api/v2.0/me/drive/, NSLocalizedDescription=unsupported URL}
2015-09-30 11:42:11.995 O365-iOS-CloudRoll[6331:144891] OneDrive SDK ERROR : Caused by request <NSMutableURLRequest: 0x7fc1a26c8cf0> { URL: _api/v2.0/me/drive/ }

is there something i am missing?
at first i thought there might be a different scopes string in the first place, but looking back at the log, is the URL valid?

thanks again!

signout not work?

[self.client signOutWithCompletion:^(NSError *error) {
self.client = nil;
if (error) {
NSLog(@"注销失败");
}else{
NSLog(@"注销成功");
}
}];

I wait a long time ,but signOut not work ,and can't see the NSLog .I also change wifi to Cellular network,not work too.
SDK version 1.0.5
my Cellular network and wifi is in China

oneDriveAccountStore.plist in Documents folder

Hello I found there is a file oneDriveAccountStore.plist in documents folder once login. This maybe cause some issues. Some document based app may open this folder to users so they can download files in Documents folder from iTunes. User can also choice to delete files via iTunes. And in my app, I will list all the files under documents for user to operate and I have to filter out these files now. It would be better to put the onedrive relatived files under cache folder.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.