OneDrive / onedrive-sdk-ios

OneDrive SDK for iOS
https://dev.onedrive.com
Other
100 stars 87 forks source link

ODAuthErrorKey 400 "bad request" when performing requests #176

Open bvirlet opened 7 years ago

bvirlet commented 7 years ago

Hello,

Some of the users of our app Genius Scan (http://dl.tglapp.com/genius-scan) are seeing "bad request" error when choosing a directory to export to, or exporting a file to OneDrive. They were able to properly login with their account (see code below). We are unable to reproduce this issue.

We're using the OneDrive SDK together with ADAL iOS. We support both "regular" and "business" user accounts (see below for how we configure the client).

On my side, I'm able to connect, select a directory and export to both types of accounts. We've thousands of users not having any problem (it's not a big misconfiguration on our side, it seems to be working for 99.99% of them).

One of the users with the issue mentions that he has a OneDrive "Home" account (so, I imagine a Office 360 Family Home account). I just tried to subscribed to one (as opposed to just using a free account) but wasn't able to reproduce the issue.

Could you help me with that? What specific conditions could lead to this issue?

I'm giving below some context:

self.configuration.microsoftAccountAppId = @"<MicrosoftAppID>";
self.configuration.microsoftAccountScopes = [@"wl.signin wl.offline_access onedrive.readwrite" componentsSeparatedByString:@" "];
self.configuration.microsoftAccountFlags = nil;
self.configuration.microsoftAccountApiEndpoint = [NSString stringWithFormat:@"%@/%@", OD_MICROSOFT_ACCOUNT_ENDPOINT, OD_MICROSOFT_ACCOUNT_API_VERSION];

self.configuration.activeDirectoryAppId = @"<ActiveDirectoryAppID>";
self.configuration.activeDirectoryCapability = @"MyFiles";
self.configuration.activeDirectoryRedirectURL = @"<ActiveDirectoryRedirectURL>";
self.configuration.activeDirectoryFlags = nil;
self.configuration.activeDirectoryResourceId = nil;
self.configuration.activeDirectoryApiEndpointURL = nil;
// Fix: https://github.com/OneDrive/onedrive-sdk-ios/issues/90
[[ADAuthenticationSettings sharedInstance] setSharedCacheKeychainGroup:nil];

Users log in successfully with:

 ODClient *client = [[ODClient alloc] init];
    client.logger = self.configuration.logger;
    [client authenticateWithAppConfig:self.configuration completion:^(NSError *error){
 …

We then send a file with:

ODItemRequestBuilder *builder = [client.root itemByPath:[NSString stringBySanitizingFilename:exportContainer.exportable.exportedFilename forbiddenCharacters:@"*?\"<>|"]];

[[builder contentRequestWithOptions:@[[ODNameConflict replace]]]
 uploadFromFile:[NSURL fileURLWithPath:filePathToExport]
 completion:^(ODItem *response, NSError *error) {
     if (error) {
         DDLogError(@"[OneDrive] Error uploading file: %@", error);
         // ...
         return;
     }
     // Success !
 }];
magicboker commented 7 years ago

I had the same issues, too!

bvirlet commented 6 years ago

Hello! Can someone from Microsoft help us with this? This is still an ongoing issue and affecting a lot of OneDrive for Business users of our app.

magicboker commented 6 years ago

You need to use Microsoft Graph SDK instead of this SDK.

bvirlet commented 6 years ago

Can you elaborate :) ?

magicboker commented 6 years ago

If you need a ready-to-go solution for OneDrive SDK (supports OneDrive for Business), please email to me via magicboker@gmail.com

bvirlet commented 5 years ago

Hi Microsoft OneDrive team, would you have any input on this? This is still affecting us!