-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OneDrive for business? #16
Comments
We're in Beta support for OneDrive for Business. Really, the main thing you have to change is the
So you just need to know your tenant prefix, substitute it into the URL above, then give that to the After that, you use the Python SDK the same against both services. |
Thanks a lot for the quick reply. I will give that a try. |
Sorry if I am asking dumb questions, but if I want to adapt, say, |
Please take a look at the StackOverflow thread about this: http://stackoverflow.com/questions/37233669/onedrive-api-python-sdk-points-to-login-live-com-not-mydomain-sharepoint-com/37244587?noredirect=1#comment62021706_37244587 If you still have questions after that, let me know! |
I tried those suggestions in the URL, but still can't get it right. Could you point me where is the problem in this code? It keeps redirecting me to the consumer login page, not my school's login page.
|
First off, do this RIGHT NOW: edit your comment and remove your You are creating onedrivesdk.AuthProvider.AUTH_SERVER_URL = "https://login.microsoftonline.com/common/oauth2/authorize"
onedrivesdk.AuthProvider.AUTH_TOKEN_URL = "https://login.microsoftonline.com/common/oauth2/token" OneDrive for Business does not require scopes, so just delete the contents of the If you have any other issues, go ahead and post them. Make sure to post it with any error messages you're getting, as they'll be helpful in further debugging. |
You can get further information about AAD authentication on OneDrive here: https://dev.onedrive.com/auth/aad_oauth.htm. |
I edited the message and removed the client secret. It does not seem to be authenticated anywhere, but it doesn't hurt to be sure. The client secrets could also be removed from the example files in here Github, since if someone runs them, security can get compromised. Now it redirects to the correct page, but still seems to not work just right, but outputs "Bad request" errors. If i am logged out from the school account, the error is |
It sounds like your app has not been registered with your ODB tenant. You can read more here: https://dev.onedrive.com/app-registration.htm#register-your-app-for-onedrive-for-business. |
Hello , .. following @cdmayer 's instructions I was wable to authenticate , .. now I'm stuck in the authenticate method , .. I'm getting invalid_resource error, here's the example source code, and the terminal output: import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
redirect_uri = "http://localhost:8080"
client_secret = "removed"
onedrivesdk.AuthProvider.AUTH_SERVER_URL = "https://login.microsoftonline.com/3c8cb82e-4ec9-4e07-8357-e28f1d4738da/oauth2/authorize"
onedrivesdk.AuthProvider.AUTH_TOKEN_URL = "https://login.microsoftonline.com/3c8cb82e-4ec9-4e07-8357-e28f1d4738da/oauth2/token"
client = onedrivesdk.get_default_client(client_id='a52fc71b-9d88-4544-98bc-01b906f368d6',
scopes=[])
auth_url = client.auth_provider.get_auth_url(redirect_uri)
#this will block until we have the code
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
client.auth_provider.authenticate(code, redirect_uri, client_secret)
Terminal output: (I added a couple of prints to the http_response.py to see the complete response):
|
Your url's are incorrect. You should have the following: onedrivesdk.AuthProvider.AUTH_SERVER_URL = "https://login.microsoftonline.com/common/oauth2/authorize"
onedrivesdk.AuthProvider.AUTH_TOKEN_URL = "https://login.microsoftonline.com/common/oauth2/token" |
Hi , .. i just changed the URLs as suggested, getting the same error, here's more info, I hardcoded the a "resource" key in the authenticate method: params = {
"code": code,
"client_id": self.client_id,
"redirect_uri": redirect_uri,
"grant_type": "authorization_code",
"resource": "https://cnpx-my.sharepoint.com/"
} the output had no errors:
What do you think ? BTW, thanks for your quick reply ! |
UPDATE: I kept the workaround above, and managed to upload a file to my OneDrive business account by hardcoding the API endpoint URL in extensions/onedrivesdk_helper.py at the return statement as follows: return OneDriveClient("https://cnpx-my.sharepoint.com/_api/v2.0/",
auth_provider,
http_provider) So, it's running, I guess I need clean solution instead of hardcoding UPDATE: @ilmaisin is not using the default client, thats the clean way |
Not sure if you already figured this out, but you shouldn't be using http_provider = HttpProvider()
auth_provider = AuthProvider(http_provider, client_id, [])
client = OneDriveClient("your_url", auth_provider, http_provider) |
yes I figured it out, too late !, thanks ! |
Does this SDK support OneDrive for business?
Thanks.
The text was updated successfully, but these errors were encountered: