Comments (7)
It's not clear to me what the error is here? What's not working? Do you get a stack trace? If so, please post it here as well.
from exchangelib.
Closing. Feel free to reopen if you get back to this.
from exchangelib.
Auth type: <requests_oauthlib.oauth2_auth.OAuth2 object at 0x000000FA4AEF2730>
URL: https://outlook.office365.com/EWS/Exchange.asmx
HTTP adapter: <requests.adapters.HTTPAdapter object at 0x000000FA4AEF25B0>
Allow redirects: False
Streaming: False
Response time: 0.7029999999795109
Status code: 403
Request headers: {'User-Agent': 'exchangelib/4.8.0 (python-requests/2.28.1)', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive', 'Content-Type': 'text/xml; charset=utf-8', 'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkZUS3Z1QWZCRkJEUEFidWRqTXJhSjVmNWR0aUZWSUEwMVlBNWpCV2xTYUEiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSIsImtpZCI6IjlHbW55RlBraGMzaE91UjIybXZTdmduTG83WSJ9.eyJhdWQiOiJodHRwczovL291dGxvb2sub2ZmaWNlMzY1LmNvbSIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0LzRjZTliNmFjLTFlNGMtNGUxOC1iMzBlLTM3NzYzZmMwMDc4Ny8iLCJpYXQiOjE2OTcwNTQ1MjksIm5iZiI6MTY5NzA1NDUyOSwiZXhwIjoxNjk3MDU4NDI5LCJhaW8iOiJFMkZnWUtoWVhlSmZYcEJxTzJQTEl0NFRSOWI5QlFBPSIsImFwcF9kaXNwbGF5bmFtZSI6ImVIU0RXU2VydmljZURlc2tSZXBvcnRpbmciLCJhcHBpZCI6IjczOWMyYmUzLWViNGEtNGE4MS04ODM1LThiMDM2YmY1MjIyOCIsImFwcGlkYWNyIjoiMSIsImlkcCI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0LzRjZTliNmFjLTFlNGMtNGUxOC1iMzBlLTM3NzYzZmMwMDc4Ny8iLCJvaWQiOiI5N2Q1MDU0ZS1hNDliLTQ3MTItYmU2My0wZjZmNjZjM2I0NWMiLCJyaCI6IjAuQVc0QXJMYnBURXdlR0U2ekRqZDJQOEFIaHdJQUFBQUFBUEffemdBQUFBQUFBQUJ1QUFBLiIsInNpZCI6IjEwMTc1ODIwLWI4ZTgtNGE1Ni05ZDVkLTZhNDA5ODAwYjc3OCIsInN1YiI6Ijk3ZDUwNTRlLWE0OWItNDcxMi1iZTYzLTBmNmY2NmMzYjQ1YyIsInRpZCI6IjRjZTliNmFjLTFlNGMtNGUxOC1iMzBlLTM3NzYzZmMwMDc4NyIsInV0aSI6Ii1NTnBOeEpydVVlXy1FLVdhbjQwQUEiLCJ2ZXIiOiIxLjAiLCJ3aWRzIjpbIjA5OTdhMWQwLTBkMWQtNGFjYi1iNDA4LWQ1Y2E3MzEyMWU5MCJdfQ.PSuHb_zV4yutRPxcuGk6o6AyFkhuKSBAMFoO1u34ip7IQfpoUaPy90rTbAot_6c1tUWGNAZIEIrhxTMS63EbW_ubI1kLM6iOf9XuXzcx1MD5b4XVZQ1gUL6yJfzoIbwbuVI0iTtATHl-UNMOoi_nCFsi5yw2j3WW5h7rOrV5rn_FgWn_P6wOfeJVjuxUlmRnnhIY3ziD-XPDVJRoUJYE_gAX3wd8re2VceeiiVT5PP807KOC0mz7FDAnHF9bu7gQlfTBvwqCNBW3IlU0o5IBJMGYvCwULhg1wM9dhaTs_vEpe9ID6rdpeJKe7khpawso5SqQZ7_WEfasG76-dSoj0w', 'Cookie': 'exchangecookie=91c983cf35124f6498a78cbf0846c606', 'Content-Length': '637'}
Response headers: {'Cache-Control': 'private', 'Content-Type': 'text/xml; charset=utf-8', 'Server': 'Microsoft-IIS/10.0', 'request-id': 'e7ac09d2-c34d-1880-c1b0-b3edd354de05', 'Alt-Svc': 'h3=":443",h3-29=":443"', 'X-CalculatedFETarget': 'YQZPR01CU005.internal.outlook.com', 'X-BackEndHttpStatus': '403, 403', 'Set-Cookie': 'exchangecookie=91c983cf35124f6498a78cbf0846c606; path=/; secure', 'WWW-Authenticate': 'Bearer client_id="00000002-0000-0ff1-ce00-000000000000", trusted_issuers="00000001-0000-0000-c000-000000000000@", token_types="app_asserted_user_v1 service_asserted_app_v1", error="invalid_token"', 'X-CalculatedBETarget': 'YQBPR1101RB5301.TDPRD01.PROD.OUTLOOK.COM', 'X-RUM-Validated': '1', 'X-RUM-NotUpdateQueriedPath': '1', 'X-RUM-NotUpdateQueriedDbCopy': '1', 'x-ms-appId': '739c2be3-eb4a-4a81-8835-8b036bf52228', 'Restrict-Access-Confirm': '1', 'x-ms-diagnostics': '2000008;reason="The token contains not enough scope to make this call.";error_category="invalid_grant"', 'X-AspNet-Version': '4.0.30319', 'X-BeSku': 'WCS7', 'X-DiagInfo': 'YQBPR0101MB5301', 'X-BEServer': 'YQBPR0101MB5301', 'X-Proxy-RoutingCorrectness': '1', 'X-Proxy-BackendServerStatus': '403', 'X-FEProxyInfo': 'CH2PR14CA0049.NAMPRD14.PROD.OUTLOOK.COM', 'X-FEEFZInfo': 'MDW', 'X-FEServer': 'YQZPR01CA0112, CH2PR14CA0049', 'X-FirstHopCafeEFZ': 'MDW', 'X-Powered-By': 'ASP.NET', 'Date': 'Wed, 11 Oct 2023 20:07:09 GMT', 'Content-Length': '0'}
Request XML: b'\n<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><s:Header><t:RequestServerVersion Version="Exchange2016"/><t:ExchangeImpersonation><t:ConnectingSID><t:PrimarySmtpAddress>[email protected]</t:PrimarySmtpAddress></t:ConnectingSID></t:ExchangeImpersonation></s:Header><s:Body><m:ResolveNames ReturnFullContactData="false"><m:UnresolvedEntry>xxx</m:UnresolvedEntry></m:ResolveNames></s:Body></s:Envelope>'
Response XML: b''
Traceback (most recent call last):
File "E:/Python_Proj/SD_Stats/Pritam.py", line 33, in
account = Account(primary_smtp_address=address,
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\account.py", line 204, in init
self.version = self.protocol.version.copy()
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\protocol.py", line 485, in version
self.config.version = Version.guess(self, api_version_hint=self._api_version_hint)
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\version.py", line 233, in guess
list(ResolveNames(protocol=protocol).call(unresolved_entries=[name]))
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\services\common.py", line 188, in _elems_to_objs
for elem in elems:
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\services\common.py", line 246, in _chunked_get_elements
yield from self._get_elements(payload=payload_func(chunk, **kwargs))
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\services\common.py", line 266, in _get_elements
yield from self._response_generator(payload=payload)
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\services\common.py", line 228, in _response_generator
response = self._get_response_xml(payload=payload)
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\services\common.py", line 343, in _get_response_xml
r = self._get_response(payload=payload, api_version=api_version)
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\services\common.py", line 298, in _get_response
r, session = post_ratelimited(
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\util.py", line 915, in post_ratelimited
protocol.retry_policy.raise_response_errors(r) # Always raises an exception
File "C:\Users\microinfo\AppData\Local\Programs\Python\Python38\lib\site-packages\exchangelib\protocol.py", line 695, in raise_response_errors
raise MalformedResponseError(
exchangelib.errors.MalformedResponseError: Unknown failure in response. Code: 403 headers: {'Cache-Control': 'private', 'Content-Type': 'text/xml; charset=utf-8', 'Server': 'Microsoft-IIS/10.0', 'request-id': 'xxx-c34d-1880-xx-b3edd354de05', 'Alt-Svc': 'h3=":443",h3-29=":443"', 'X-CalculatedFETarget': 'YQZPR01CU005.internal.outlook.com', 'X-BackEndHttpStatus': '403, 403', 'Set-Cookie': 'exchangecookie=xxx; path=/; secure', 'WWW-Authenticate': 'Bearer client_id="xxx-0000-0ff1-xx-000000000000", trusted_issuers="00000001-0000-0000-c000-000000000000@", token_types="app_asserted_user_v1 service_asserted_app_v1", error="invalid_token"', 'X-CalculatedBETarget': 'YQBPR0101MB5301.CANPRD01.PROD.OUTLOOK.COM', 'X-RUM-Validated': '1', 'X-RUM-NotUpdateQueriedPath': '1', 'X-RUM-NotUpdateQueriedDbCopy': '1', 'x-ms-appId': 'xx-eb4a-4a81-8835-xx', 'Restrict-Access-Confirm': '1', 'x-ms-diagnostics': '2000008;reason="The token contains not enough scope to make this call.";error_category="invalid_grant"', 'X-AspNet-Version': '4.0.30319', 'X-BeSku': 'WCS7', 'X-DiagInfo': 'YQBPR0101MB5301', 'X-BEServer': 'YQBPR0101MB5301', 'X-Proxy-RoutingCorrectness': '1', 'X-Proxy-BackendServerStatus': '403', 'X-FEProxyInfo': 'CH2PR14TR0049.NAMPRD14.PROD.OUTLOOK.COM', 'X-FEEFZInfo': 'MDW', 'X-FEServer': 'YQZPR01CA0112, CH2PR14CA0049', 'X-FirstHopCafeEFZ': 'MDW', 'X-Powered-By': 'ASP.NET', 'Date': 'Wed, 11 Oct 2023 20:07:09 GMT', 'Content-Length': '0'} content:
DEBUG:exchangelib.protocol:Server outlook.office365.com: Closing sessions
from exchangelib.
its shows invalid token/grant in response.
from exchangelib.
Yeah, that usually means that the OAuth client is generering tokens that are not valid for use with the EWS API. You need to either forlod rhe documentation for creating an Azure client, or get help from your Azure admins on correctly configuring the OAuth client.
from exchangelib.
is there anything wrong in code? i informed my azure admin about this issue but they asked me to change the code but I don't see any issue with code.
Pritam
from exchangelib.
Looking again at the initial code you posted, you specified Basic auth in the Configuration
object, which is wrong. Also, your service_endpoint
points to an OAuth token URL but should point to the URL of the EWS service of your Exchange server.
from exchangelib.
Related Issues (20)
- Problem when access delegate inbox. HOT 1
- Incorrect "field_uri" in BaseFolder._distinguished_id HOT 1
- error in function to_xml in fields.AppointmentStateField HOT 7
- Error creating inbox rules HOT 4
- Multiple Email address inbox Stream subscription HOT 1
- Unnable to access shared calendar without permission on the mailbox root folder HOT 6
- Error in conver rule from xml
- Typo in Exchange 2019 version HOT 1
- Can't browse public_folders_root anymore HOT 32
- exchangelib.errors.ErrorAccessDenied: Not allowed to access Non IPM folder. HOT 23
- Can junk mail rules be created by exchangelib? HOT 1
- Validation rule error when manage inbox rules HOT 3
- `folder.parts` no longer returns root of hierarchy in list of parts (5.2.1) HOT 9
- `ErrorNonExistentMailbox` in version 5.2.1 but not in 5.2.0 HOT 6
- exchangelib.errors.UnauthorizedError: Invalid credentials for https://[domain].de/EWS/Exchange.asmx HOT 6
- Create calendar appointment in another account as access data, the appointment is created in the access account. HOT 3
- Get all Public Folders HOT 23
- ErrorInvalidSchemaVersionForMailboxVersion with exchangelib v5.2.1 and Exchange server version 15.2.1544.4 HOT 45
- EOF occurred in violation of protocol HOT 4
- ValueError trying to delete a rule HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exchangelib.