Giter Club home page Giter Club logo

msgraph-training-python's Issues

SSLCertVerificationError when following the tutorial

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?

List inbox and send mail return `Exception: Content type text/html does not have a factory registered to be parsed`

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:

  1. Follow the tutorial, register an application, etc.
  2. 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]
  1. 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**
  1. 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

I'm using a free Azure account, here's screenshot of the app overview:
image

Here are the permissions:
image

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?

_assign_field_values tries to iterate over a string

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:

  1. copy the app-only tutorial
  2. run the code
  3. See error

Expected behavior
The code should not throw the exception.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: MacOS 13.0.1
  • Browser no browser involved
  • Version 22

Dependency versions

  • Authentication library (MSAL, etc.) version: 1.21.0
  • Graph library (Graph SDK, REST library, etc.) version: 1.0.0a4

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.)

broken with kiota-serializers-json 0.3.5

Where did you get the code?

  • [ X] Downloaded from GitHub

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:

  1. in requirements.txt change:

    'microsoft-kiota-serializers-json==0.3.1'

to

'microsoft-kiota-serializers-json==0.3.5'

  1. 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

  • msal: 1.22.0
  • msgraph-sdk: 1.0.0a12

Additional context
Not really a bug for this project, but don't know who to contact.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.