Where did you get the code?
Describe the bug
Listing or sending email using the user-auth\graphtutorial
code from this repo returns the following error (full traceback below):
Exception: Content type text/html does not have a factory registered to be parsed
To Reproduce
Steps to reproduce the behavior:
- Follow the tutorial, register an application, etc.
- In
user-auth\graphtutorial
, run python main.py
(Python 3.11)
$ python main.py
Python Graph Tutorial
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ABCD1234 to authenticate.
Hello, Francois XXX
Email: [email protected]
- Choose option 1
Please choose one of the following options:
0. Exit
1. Display access token
2. List my inbox
3. Send mail
5. Make a Graph call
1
User token: **redacted**
- Choose option 3 (send email)
Please choose one of the following options:
0. Exit
1. Display access token
2. List my inbox
3. Send mail
4. Make a Graph call
3
Traceback (most recent call last):
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\main.py", line 112, in <module>
asyncio.run(main())
File "C:\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\main.py", line 45, in main
await send_mail(graph)
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\main.py", line 102, in send_mail
await graph.send_mail('Testing Microsoft Graph', 'Hello world!', user_email or '')
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\graph.py", line 93, in send_mail
await self.user_client.me.send_mail.post(body=request_body)
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\.env\Lib\site-packages\msgraph\generated\users\item\send_mail\send_mail_request_builder.py", line 50, in post
return await self.request_adapter.send_no_response_content_async(request_info, error_mapping)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\.env\Lib\site-packages\kiota_http\httpx_request_adapter.py", line 365, in send_no_response_content_async
await self.throw_failed_responses(response, error_map, parent_span, parent_span)
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\.env\Lib\site-packages\kiota_http\httpx_request_adapter.py", line 464, in throw_failed_responses
root_node = await self.get_root_parse_node(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\.env\Lib\site-packages\kiota_http\httpx_request_adapter.py", line 400, in get_root_parse_node
return self._parse_node_factory.get_root_parse_node(response_content_type, payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\development\tests\msgraph-training-python\user-auth\graphtutorial\.env\Lib\site-packages\kiota_abstractions\serialization\parse_node_factory_registry.py", line 50, in get_root_parse_node
raise Exception(
Exception: Content type text/html does not have a factory registered to be parsed
Expected behavior
It should send the email with no error.
Screenshots
Checking the token claims on jwt.ms, I can see the scopes for the application are correct:
![image](https://private-user-images.githubusercontent.com/4020546/310911431-00056f5b-3bd8-48bf-93fc-a6b8003a8a15.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkwNDE3MjAsIm5iZiI6MTcxOTA0MTQyMCwicGF0aCI6Ii80MDIwNTQ2LzMxMDkxMTQzMS0wMDA1NmY1Yi0zYmQ4LTQ4YmYtOTNmYy1hNmI4MDAzYThhMTUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjJUMDczMDIwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjFlMWNhMTQxZGE0OWNmMzg1ZDA3YTZhNDA0Y2E3NmMyNDExNjdhNDc1ZGI5NGQ3YjQ4NzY2OTlhYmM3MTBhYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Py1NMATFsOj2AIXbhQR5TV9cl1j3RMcDq6zYpQUty0M)
I'm using a free Azure account, here's screenshot of the app overview:
![image](https://private-user-images.githubusercontent.com/4020546/310913345-9824eb05-2c29-4754-8c74-81953d580809.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkwNDE3MjAsIm5iZiI6MTcxOTA0MTQyMCwicGF0aCI6Ii80MDIwNTQ2LzMxMDkxMzM0NS05ODI0ZWIwNS0yYzI5LTQ3NTQtOGM3NC04MTk1M2Q1ODA4MDkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjJUMDczMDIwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzEwMTU3Y2FlZmU3N2Y0M2QzZmZhMGNiODAxMTRmMWYxNzkxNmRmMWY2ZGZhZWNhMTQyM2Q5MGFiNjE0YTAyNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.GO09Z4C6QUF5RiBEPP90YydpxxG2DR7Qwfvj_apCdVQ)
Here are the permissions:
![image](https://private-user-images.githubusercontent.com/4020546/310913864-7f7d60c2-3a7e-4195-af1a-934770fb140e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkwNDE3MjAsIm5iZiI6MTcxOTA0MTQyMCwicGF0aCI6Ii80MDIwNTQ2LzMxMDkxMzg2NC03ZjdkNjBjMi0zYTdlLTQxOTUtYWYxYS05MzQ3NzBmYjE0MGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjJUMDczMDIwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTkwMmQ5YWE0ODFkYjQyNjAyY2IxOGNiZjM2MTY1MmQzYzg2Y2U2MTkxODk1ZDdkYWU0ZjE1ZTJkZTM4Yjk0ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.HxkHhwEN8q7BgtRrXolb_u0MbnMoCjo-n9lhS4ys9Nw)
Desktop (please complete the following information):
- OS: Windows 11 Enterprise Version 10.0.22631 Build 22631
- Browser: Chrome 122.0.6261.96
Dependency versions
$ pip freeze
aiohttp==3.9.2
aiosignal==1.3.1
anyio==4.0.0
async-timeout==4.0.3
attrs==23.1.0
azure-core==1.29.5
azure-identity==1.15.0
certifi==2023.7.22
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==41.0.6
Deprecated==1.2.14
exceptiongroup==1.1.3
frozenlist==1.4.0
h11==0.14.0
h2==4.1.0
hpack==4.0.0
httpcore==0.18.0
httpx==0.25.0
hyperframe==6.0.1
idna==3.4
importlib-metadata==6.8.0
microsoft-kiota-abstractions==1.0.0
microsoft-kiota-authentication-azure==1.0.0
microsoft-kiota-http==1.0.0
microsoft-kiota-serialization-json==1.0.0
microsoft-kiota-serialization-text==1.0.0
msal==1.24.1
msal-extensions==1.0.0
msgraph-core==1.0.0
msgraph-sdk==1.1.0
multidict==6.0.4
opentelemetry-api==1.20.0
opentelemetry-sdk==1.20.0
opentelemetry-semantic-conventions==0.41b0
pendulum==2.1.2
portalocker==2.8.2
pycparser==2.21
PyJWT==2.8.0
python-dateutil==2.8.2
pytzdata==2020.1
pywin32==306
requests==2.31.0
six==1.16.0
sniffio==1.3.0
std-uritemplate==0.0.46
typing_extensions==4.8.0
urllib3==2.0.7
wrapt==1.15.0
yarl==1.9.2
zipp==3.17.0
Additional context
Using Git Bash.
Out of curiosity, why do I need an application for user authentication?