Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

OneDrive for Business - New Apps will not work due to Office 365 Discovery API Deprecation #202

Open
mmcguill opened this issue Sep 30, 2018 · 10 comments

Comments

@mmcguill
Copy link

mmcguill commented Sep 30, 2018

Hi,

I'm using this library successfully for OneDrive personal in my app, and wanted to allow people to use OneDrive for Business in my app. Unfortunately this functionality appears to be broken for new applications currently. You will receive the following error message on your console:

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

The error message you get in the console unfortunately and frustratingly buries the underlying error, which I had to debug through to find. The actual error message turns out to be:

"message" : "The app ID is blocked for access of the O365 Discovery Service."
"code" : "101, Microsoft.Online.Services.O365Discovery.O365DiscoveryException"

I found this by debugging through to ODBusinessAuthProvider.m (Ln. 131) where you'll see that the responseObject contains those 2 key/value pairs above.

A quick search online for this error reveals a few people having this issue recently:

https://stackoverflow.com/questions/51425968/app-blocked-calling-o365-discovery-service

The cause is due to Microsoft deprecating the https://api.office.com/discovery/v2.0/me/services discovery service URL for new applications:

https://developer.microsoft.com/en-us/office/blogs/migrating-from-the-office-365-discovery-service-to-microsoft-graph-to-discover-a-sharepoint-root-site/

I wonder if any of the contributors here are aware of this? Are there any plans to switch to the new Graph based API.

Unfortunately it looks (haven't verified) like the response from the new API is slightly different that the response from the old API, that is, it doesn't contain the expected "serviceResourceId" & "serviceEndpointUri" keys. So this means that it's not just a simple URL switch out, but a little bit of modified response handling too. Of course, I'm not an expert in this API or this project and this work could be much more involved...

You can if you like look at a minimal repro I created here:

https://github.com/mmcguill/onedrive-sdk-discovery-service-problem-minimal-repro

Please feel free to change App Id and Redirect URI for your newly created azure app, if you don't trust I've done the correct configuration etc.

Since I'd really like to get this working as soon as I can for my project, I'd really appreciate if one of the contributors here could respond briefly and let me know if this project is still being actively maintained? and if so if someone is like to look into this in the near future, or if I should go away and work on some kind of fix of my own (which will inevitably be a lot more work for me, and I'll probably do a worse job given I don't know the code base or API/MS Graph Paradigms very well).

@mmcguill
Copy link
Author

mmcguill commented Oct 4, 2018

Anyone? Just to let me know if this is something that will be looked at or if this project is still being maintained at all?

Thanks!

@orumad
Copy link

orumad commented Oct 18, 2018

Hi @mmcguill,

You point me in the right direction to find a solution for this issue. Finally I found a workarround without the hassle of modify the SDK code.

We can use this to initialize the ODClient instance passing the correct resourceId and apiEndpoint:

// Swift
ODClient.setActiveDirectoryAppId(<your_app_id>, resourceId: "https://graph.microsoft.com/", apiEndpoint: "https://graph.microsoft.com/v1.0/me", redirectURL: <your_app_redirect_url>)
// Objective-C
[ODClient setActiveDirectoryAppId:<applicationId> resourceId:@"https://graph.microsoft.com/" apiEndpoint:@"https://graph.microsoft.com/v1.0/me" redirectURL:<redirectURL>];

It works! Hope this help you and others with the same ODfB issue.

Thanks for your help!

@mmcguill
Copy link
Author

This seems to do the trick @orumad, very nice trick. I'm still concerned that this project seems to be no longer maintained, but thanks for your suggestion!

@Suryaphalle
Copy link

Hello @mmcguill, I'm facing same issue for a while have you come up with any solutions for this issue.

@mmcguill
Copy link
Author

mmcguill commented Sep 9, 2019

Hi @Suryaphalle - @orumad solution above worked well for me.

@allan304
Copy link

allan304 commented Jan 4, 2020

Hi @Suryaphalle - @orumad solution above worked well for me.

Hello,
// Objective-C
[ODClient setActiveDirectoryAppId: resourceId:@"https://graph.microsoft.com/" apiEndpoint:@"https://graph.microsoft.com/v1.0/me" redirectURL:];
Mean I only need to change AppId and redirectURL ?

@allan304
Copy link

hello @mmcguill @Suryaphalle @orumad , [ODClient setActiveDirectoryAppId: resourceId:@"https://graph.microsoft.com/" apiEndpoint:@"https://graph.microsoft.com/v1.0/me" redirectURL:]; I try to replace the AppId and redirectURL with my app's, but return AADSTS500201: We are unable to issue tokens from this API version for a Microsoft account. Please contact the application vendor as they need to use version 2.0 of the protocol to support this.

@orumad
Copy link

orumad commented Jan 10, 2020

Hi @allan304

I guess they have deprecated this SDK (OneDrive SDK iOS). Due to all the problems that I have had with this SDK, I decided a while ago to replace it in my project.

@allan304
Copy link

Hi @allan304

I guess they have deprecated this SDK (OneDrive SDK iOS). Due to all the problems that I have had with this SDK, I decided a while ago to replace it in my project.

OK, thanks. I have to replace it, too. Do you replace it with MSAL? Is there a sample?

@abuzarin93
Copy link

helpfull: thanks orumad!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants