Closed psahire closed 1 year ago
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.
Closing. Feel free to reopen if you get back to this.
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'<?xml version=\'1.0\' encoding=\'utf-8\'?>\n
its shows invalid token/grant in response.
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.
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
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.
Describe the bug A clear and concise description of what the bug is.
To Reproduce If applicable, add the shortest possible script that reproduces the error.