Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

Sharepoint On-premise App-Only Authentication fails.

Open janandreschweiger opened this issue 4 years ago • 6 comments

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)

janandreschweiger avatar Apr 05 '21 08:04 janandreschweiger

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

ace-kay-law-neo avatar Apr 05 '21 10:04 ace-kay-law-neo

Same here. Thanks @vgrem for having a look.

nero-nazok avatar Apr 05 '21 10:04 nero-nazok

Isn't site_url supposed to be of the form https://abcd.sharepoint.com ?

vj68 avatar Aug 30 '21 15:08 vj68

Hi did you find a solution for this? My sharepoint on premise also doesn't have "sharepoint" in its site_url and I'm receiving IndexError: list index out of range as well . Is there a way to bypass it?

lambrosapoel avatar Jun 23 '23 09:06 lambrosapoel

Hi Is someone found a solution ? workaround ? Facing same issue with on premise instance I have seen that using Client_id/Client_secret could work instead of using user/password. My problem is that I don't have the permissions to create client_id/secret and it could be complex to obtain so I would to know if it is a real solution or not before "moving mountains"

rv2931 avatar Apr 04 '24 13:04 rv2931