To Install MSAL Client Library
pip install msal
Buy Me a Coffee? Your support is much appreciated!
ms_graph.py Source Code
Last Updated: 04/06/2022
Apr 6, 2022 | MS Graph API, Python | 15 comments
pip install msal
Last Updated: 04/06/2022
Subscribe My YouTube Channel
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Hello,
I was trying this watching your video and I cannot find the GRAPH_API_ENDPOINT
I was watching your other videos to see if I could find it but I couldn’t
if you could share it with me I will appreciate it
Regards
Hey Paul, thanks for letting me know. I have updated the script.
Thank you so much
Hello, can you send me the updated script.
Thank you.
You need to create app in http://portal.azure.com/
Hi Paul, What is python version requirement? – Thanks
Hey, i’m getting a key error, originating from your ms_graph.py file, the error was first triggered from this line of code:
access_token = generate_access_token(APP_ID, SCOPES)
and traced back to ms_graph.py file line 40,in generate_access_token:
print(‘user_code: ‘ + flow[‘user_code’])
which arose this error;
KeyError: ‘user_code’
Here’s the code i ran; https://github.com/Sam25498/Django-Projects/blob/main/demo.py
Can you help me resolve this error.
I’m also getting the same error. Have u solved that error?
Have you resolved the issue Samwel and Mohammed
Not sure if you resolved your issue, but I was able to fix this by switching the App platform to Public client/native (mobile & desktop) in Azure App Registration. I had to create a new app because I don’t think there’s a way to change the existing one.
Was this problem solved? I’m still getting this error: “print(‘user_code: ‘ + flow[‘user_code’])
~~~~^^^^^^^^^^^^^”
I went to my app in Azure -> Authentication Tab -> set ‘Allow public client flows’ to Yes. Still the error is occuring.
I even enabled ‘Access Tokens (used for implicit flows)’
Did you resolve your problem?
How?
Thank you so much. This solved my problem.
in your original app you need to allow public client flows. This can be found in the authentication tab.
Thanks, great stuff!
Removing the following lines, allows the Token to be renewed.
if datetime.now() > token_expiration:
os.remove(‘ms_graph_api_token.json’)
access_token_cache = msal.SerializableTokenCache()