O365 / python-o365

A simple python library to interact with Microsoft Graph and Office 365 API
Apache License 2.0
1.67k stars 423 forks source link

Unable to paste authenticated URL #563

Closed jwvdm closed 3 years ago

jwvdm commented 3 years ago

I am a relatively unsophisticated user, but I was able to use your library some time back to automate sending of emails from a template. This script uses standard authentication code (from what I understand from your docs):

client_id = '...'
client_secret = '...'

account = Account((client_id, client_secret))
if account.authenticate(scopes=['basic', 'message_all']):
   print('Authenticated!')

Unfortunately, when I tried to reuse this script today, I was no longer able to get it to work. The problem is that while I am able to retrieve the authenticated URL, I am not able to enter it as a response to the prompt (nothing happens when I press <return>). Below is sample output from the script, along with the response URL.

Visit the following url to give consent:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=3a5139d6-706c-491b-9c10-0ae0aaf0af7b&redirect_uri=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fnativeclient&scope=https%3A%2F%2Foutlook.office.com%2FUser.Read+https%3A%2F%2Foutlook.office.com%2FMail.Send+offline_access+https%3A%2F%2Foutlook.office.com%2FMail.ReadWrite&state=KGRVDGInnYNJU4xYPO0c23empEOMyc&access_type=offline
Paste the authenticated url here:
https://login.microsoftonline.com/common/oauth2/nativeclient?code=0.AAAAgcLuqKOqrk2sm5o5i5IV59Y5UTpscBtJnBAK4Krwr3tZAAE.AQABAAIAAABeStGSRwwnTq2vHplZ9KL4GJWFcruO5v8k9Kp5YCE81ID-04zc1Vd-ph4XKHH5HOaFBxmwBG7uYOnBJV8F8rrLW7DHraMFFaf4yBEWiw82nGEXnsV_mHN2eTU1IQcgUlxCh46ZYLC7Ik4Jac6vS7HChY_nbgXutWCh92UXzriLW7WIAQGPsLWiZ5WyZxLcAYTzWUvz8jW_rhq5msJNs_3nHDvx4IQ4E-_Qb8aKolwXz5JY8WawRdK_y_zHkvSQpewP4YXqJjiIGNNBaPFO4JkypxeRTuUqaT1vRUr4qtCeUdBmMGzKnzZ1oWvePotak-iaP2Tie6cDwAtPgLZwjDFJxRc0dIsqegi9HCXcaeu25D_0TxARknj8pf8YCIU0ysP1y4m-s2Xyc5AuIVkr1pikZNl8bTV_9-J0TniVds-mO56bspVOgMAu_i7lG_DWnrZVIiuK9E5kQfVAqcPxrD0_zXVnsSN_kg2xgtdYwlBciv5IN-OcjcAYCiJVMv0uoj2EtstdhjBcWsifHq4JSLEUF4qviMdKS0BjEXGYm7WLCyYH8g8rt8CBAswhAjjY-LC2q1b-R8sPvVynmMp-nvAGMDch126tVtBttBx1EPzB0wO-aCtY0bE1Wj_wAzaM6acFeUd8LFXyUzGGxC5GE9hB22cBGOB69AdFdCFiV9GS_uXJP_Gjao2hRP-iIudFYOi3-YiwlWMKa-0YcHlnMITZimNRpRPWQxWC9mx5eVRFDI7bIxb3K77UZBl15Y6UvOfma-GVZEtungmFrs8kjQ1IusAQ7hUPmsPwGCjIDiSuUxhIujxpnucnblrvKJo6jJ68TlDjQvHmvSFz-B2sWOiz2Y-OjHGpN9JfzJJ8PpH1OSAA&state=KGRVDGInn

This is quite possibly some form of silly error on my part – although, as I mentioned, this script did previously work. Might you have any pointers?

jwvdm commented 3 years ago

Closing. After re-reading the docs, I realized there is a MacOS specific issue that can be solved by adding import readline to the top of the script.

Thanks for your work on this library!