Office365-rest-python-client: Sharepoint On-premise App-Only Authentication fails.

Created on 5 Apr 2021  ·  2Comments  ·  Source: vgrem/Office365-REST-Python-Client

Hey everyone, I have created a local sharepoint on my computer and would like to use your package. Unfortunately the authentication fails with the following error. Others have mentioned an IndexError for user-authentication, but this error occurs when using app-only authentication and has a totally different traceback.

My sharepoint isn't connected to Azure, thus I use the local ip of my sharepoint-vm as site_url. I have successfully created and granted access as described here .

My team and I really appreciate any help.

Error:

IndexError                                Traceback (most recent call last)
<ipython-input-13-944e8be97f9f> in <module>
      5 site_url = "http://e3431a1d07c8.ngrok.io"
      6 ctx = ClientContext(site_url).with_credentials(ClientCredential('d6e22d2e-4fc6-43e1-920e-7dd7ac5d2fd0','nNCWQ+7Yo5Etyfu14kOvVegPlpy45q1tFe60A+TZSjk='))
----> 7 target_web = ctx.web.get().execute_query()
      8 print(target_web.url)
      9 

...

~/.local/lib/python3.8/site-packages/office365/runtime/auth/providers/acs_token_provider.py in process_realm_response(response)
     80             auth_values = response.headers[header_key].split(",")
     81             bearer = auth_values[0].split("=")
---> 82             return bearer[1].replace('"', '')
     83         return None
     84 

IndexError: list index out of range

Code:

import json
from office365.runtime.auth.client_credential import ClientCredential
from office365.runtime.http.request_options import RequestOptions
from office365.sharepoint.client_context import ClientContext
site_url = "http://192.168.33.2"
ctx = ClientContext(site_url).with_credentials(ClientCredential('client-id','client-secret'))
target_web = ctx.web.get().execute_query()
print(target_web.url)
question

Most helpful comment

My firm faces the exact same issue. Could you maybe have a look on this one @vgrem? We are really desperate for some help.

All 2 comments

My firm faces the exact same issue. Could you maybe have a look on this one @vgrem? We are really desperate for some help.

Same here. Thanks @vgrem for having a look.

Was this page helpful?
0 / 5 - 0 ratings