python3-connect-rest-sample icon indicating copy to clipboard operation
python3-connect-rest-sample copied to clipboard

connectsample command fails sending email

Open pchartrand opened this issue 9 years ago • 3 comments

Sample flask command allows for connection but fails sending email returning a 404.

Also, warning issued by urllib3 about unverified https request being made.

 * Running on http://localhost:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 194-413-547
127.0.0.1 - - [14/Jun/2017 16:43:02] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [14/Jun/2017 16:43:03] "GET /login HTTP/1.1" 302 -
127.0.0.1 - - [14/Jun/2017 16:43:06] "GET /login/authorized?code=OAQABAAIAAABnfiG-...969d4c517eae HTTP/1.1" 302 -
127.0.0.1 - - [14/Jun/2017 16:43:06] "GET /main HTTP/1.1" 200 -
/home/pchartrand/Envs/msgraph/lib/python3.5/site-packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
404: {
  "error": {
    "code": "ResourceNotFound",
    "message": "Resource could not be discovered.",
    "innerError": {
      "request-id": "33de9b29-299f-4c48-a3b1-641d1efaa8c4",
      "date": "2017-06-14T20:43:22"
    }
  }
}
127.0.0.1 - - [14/Jun/2017 16:43:23] "GET /send_mail?emailAddress=xxx%40xxx.ca HTTP/1.1" 200 -

pchartrand avatar Jun 14 '17 20:06 pchartrand

Thanks for the feedback on this sample. The InsecureRequestWarning is due to running the sample locally over HTTP instead of HTTPS, and we didn't include instructions on configuring HTTPS locally because that would add some configuration complexity and the sample is intended to be run locally. Note that if you deploy the sample to a site with HTTPS you can configure your app with an HTTPS redirect URI (which is the recommended practice for production use) and then the error won't occur.

I've also made a change that suppresses the warning. Can you pull that latest change to connectsample.py and see if you still have an issue? FYI, I am not able to reproduce the 404 error you experienced - the sample works for me with or without that change. So if you're still having the 404 error, it would be useful to know what type of Microsoft identity you're using when you connect - i.e., whether it's an AAD work/school organization account, live.com, Hotmail.com, etc.

dmahugh avatar Jun 19 '17 17:06 dmahugh

Thanks for the explanation. I will pull and test and then try the app over https and see if it works for me.

As for the 404 error, it does not occur when I try it with another account, so it must be related to my identity and maybe my profile settings. I normally use IMAPS with a local domain account.

pchartrand avatar Jun 20 '17 15:06 pchartrand

The insecure warning has indeed been suppressed.

I tried again using https certificates on local flask app and by defining an https redirection url instead of a plain one in the app registration page and it works.

pchartrand avatar Jun 21 '17 18:06 pchartrand