0

I'm doing my internship in a company has very high security settings, sometimes something in the network will be blocked without any notice. And I don't really have admin role for my computer. Right now I met a problem, and not sure whether it's my permission issue.

I'm trying to upload files in Python code to OneDrive for Business, it's the company account. This is the tutorial I'm using, check that OneDrive for Business part.

Before uploading the item, I should pass the authentication.

I have tested my code line by line, it worked well,

import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRequest

redirect_uri = 'http://localhost:8080'
client_secret = '[my client secret]'
client_id='[my client id]'
resourceId = "https://api.office.com/discovery/"
auth_server_url='https://login.microsoftonline.com/common/oauth2/authorize'
auth_token_url='https://login.microsoftonline.com/common/oauth2/token'

http = onedrivesdk.HttpProvider()
auth = onedrivesdk.AuthProvider(http,
                            client_id,
                            auth_server_url=auth_server_url,
                            auth_token_url=auth_token_url)
auth_url = auth.get_auth_url(redirect_uri)
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
auth.authenticate(code, redirect_uri, client_secret, resource=resourceId)
service_info = ResourceDiscoveryRequest().get_service_info(auth.access_token)

until when I am trying to get the service_info, it's empty....

Do you know why it's empty?

Or how can i keep writing the code here so that I could upload files to OneDrive for business?

Cherry Wu
  • 3,844
  • 9
  • 43
  • 63

1 Answers1

0

I get the feeling that this is happening because our SDK drops all services where the service_api_version is less than 2.0. Assuming that the service you are trying to access works with API 2.0, then you can use this workaround to get past your issue.

Community
  • 1
  • 1
D4N14L
  • 440
  • 1
  • 6
  • 10
  • Thank you very much for the reply. That code looks good, but the code I'm writing needs to be automated, so I cannot copy and paste the "code" generated by browser each time, this "code" will expire very soon too. So, based on that code, I modified my code, but no matter it's v1.0 or v2.0, I still get empty response['value']..... Here's my code: https://github.com/hanhanwu/Basic_But_Useful/blob/master/one_drive_buz_test.py – Cherry Wu Nov 01 '16 at 23:08