microsoftgraph / msgraph-training-python Goto Github PK
View Code? Open in Web Editor NEWCompleted project for Build Python apps with Microsoft Graph
License: MIT License
Completed project for Build Python apps with Microsoft Graph
License: MIT License
Hi,
I cloned the repo and followed the tutorial, but keep getting the following error:
azure.core.exceptions.ServiceRequestError: Cannot connect to host login.microsoftonline.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)')]
I'm running Python 3.10 on Macos, using a virtualenv. What am I doing wrong?
There are important files that Microsoft projects should all have that are not present in this repository. A pull request has been opened to add the missing file(s). When the pr is merged this issue will be closed automatically.
Microsoft teams can learn more about this effort and share feedback within the open source guidance available internally.
installing
msgraph-sdk
now installs the
microsoft-kiota-abstractions==0.7.0
it was not a problem with
microsoft-kiota-abstractions==0.6.0
going through issue
microsoftgraph/microsoft-graph-training#164
I saw
this commit
6fe994e
uses
microsoft-kiota-abstractions==0.6.0
is there an updated use example for 0.7.0?
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:
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]
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**
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:
I'm using a free Azure account, here's screenshot of the app overview:
Desktop (please complete the following information):
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?
Where did you get the code?
[- [ ] Downloaded from GitHub
Describe the bug
_assign_field_values throws AttributeError: 'str' object has no attribute 'items' in kiota_serialization_json/json_parse_node.py
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The code should not throw the exception.
Screenshots
N/A
Desktop (please complete the following information):
Dependency versions
Additional context
My code differs slightly from the tutorial in that I'm getting the information you put in a config file from the environment, but other than that it's identical. If I edit kiota_serialization_json/json_parse_node.py and add print(object_dict)
right before the for key, val in object_dict.items():
line, I am getting the expected data, but it's not being parsed (it's still a string.)
Where did you get the code?
Describe the bug
This is not a bug. As the project is written, everything works fine.
The requirements modules are out of date. More recent versions are available for many. Updating all to the latest versions, on python 3.10, I find that microsoft-kiota-serializers-json 0.3.5 breaks this project, while microsoft-kiota-serializers-json 0.3.4 works.
To Reproduce
Steps to reproduce the behavior:
in requirements.txt change:
'microsoft-kiota-serializers-json==0.3.1'
to
'microsoft-kiota-serializers-json==0.3.5'
run:
python -m pip install -r requirements.txt
python main.py
Workaround:
Don't microsoft-kiota-serializers-json past version 0.3.4
Expected behavior
Expect
Hello: (user)
Email: (address)
Get
Hello: None
Email: None
Desktop (please complete the following information):
OS: Debian 11
Python 3.10
Dependency versions
Additional context
Not really a bug for this project, but don't know who to contact.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.