简体   繁体   中英

upload file to sharepoint using python office 365

I'm trying to upload file to sharepoint using app only credentials but it fails at the auth step. not sure what is the problem here, also verified the permission on the app id but still no luck.

any inputs is greatly appreciated!!

error message

TypeError: init () got an unexpected keyword argument 'url'

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File
site_url = 'https://contoso.sharepoint.com/'
 app_principal = {
     'client_id': '--client-id-goes-here--',
     'client_secret': '--client-secret-goes-here--',
 }
    
 context_auth = AuthenticationContext(url=site_url)
 context_auth.acquire_token_for_app(client_id=app_principal['client_id'], client_secret=app_principal['client_secret'])
    
 ctx = ClientContext(site_url, context_auth)
 web = ctx.web
 ctx.load(web)
 ctx.execute_query()
 print("Web site title: {0}".format(web.properties['Title']))

The url should be like following

site_url = 'https://contoso.sharepoint.com/sites/xxx'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM