-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
TypeError: 'str' object is not callable`ClientContext #877
Comments
I'm hitting the same error. Using Office365-REST-Python-Client 2.5.11 (and msal 1.30.0). |
I could make it work in my particular Python script using SharePoint Online tenant_id and client_id combined with browser authentication by making the two changes below in .../site-packages/office365/runtime/auth/authentication_context.py
|
The error occurs because with_access_token expects a function that returns the token, not the token string itself. This is necessary because with_access_token is designed to call the function dynamically to retrieve a fresh token when needed, which is important in OAuth2 flows where tokens can expire and need to be refreshed. How to Fix the Issue
Additionally, note that my Token class is mandatory because there is an error in the code that formats the token using the function:
This function expects a token as a dictionary but uses attribute accessors (.tokenType, .accessToken) instead of dict.get(). To resolve this, I introduced a Token class with attributes to handle the formatting correctly. |
Hi,
I am trying to access sharepoint sites using msal.
I am getting the access token correctly but it throws following error while running the query on the context:
context.execute_query() File "/opt/conda/lib/python3.10/site-packages/office365/runtime/client_runtime_context.py", line 173, in execute_query self.pending_request().execute_query(qry) File "/opt/conda/lib/python3.10/site-packages/office365/runtime/client_request.py", line 37, in execute_query response = self.execute_request_direct(request) File "/opt/conda/lib/python3.10/site-packages/office365/runtime/client_request.py", line 46, in execute_request_direct self.beforeExecute.notify(request) File "/opt/conda/lib/python3.10/site-packages/office365/runtime/types/event_handler.py", line 41, in notify listener(*args, **kwargs) File "/opt/conda/lib/python3.10/site-packages/office365/sharepoint/client_context.py", line 283, in _authenticate_request self.authentication_context.authenticate_request(request) File "/opt/conda/lib/python3.10/site-packages/office365/runtime/auth/authentication_context.py", line 249, in authenticate_request self._authenticate(request) File "/opt/conda/lib/python3.10/site-packages/office365/runtime/auth/authentication_context.py", line 168, in _authenticate self._cached_token = token_func() TypeError: 'str' object is not callable
As far my understanding, all required permissions to the app are granted through AAD portal
Am I missing something? Or any other permissions should be added? Pleas help
The text was updated successfully, but these errors were encountered: