Seems this don´t works
Ive tried today with all steps what say (account, registering app, etc.)
- In windows with python3.4 and all flask/request installed
- In linux with python 3.5.2
and the results is the same:
flask_oauthlib.client.OAuthException: Invalid response from microsoft
The traceback says Traceback (most recent call last)
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/jl/Documents/LiClipse Workspace/python3_gui/python3-connect-rest-sample-master/connect/__init__.py", line 54, in authorized
response = microsoft.authorized_response()
File "/usr/local/lib/python3.5/dist-packages/flask_oauthlib/client.py", line 677, in authorized_response
data = self.handle_oauth2_response()
File "/usr/local/lib/python3.5/dist-packages/flask_oauthlib/client.py", line 664, in handle_oauth2_response
[Open an interactive python shell in this frame] type='invalid_response', data=data
Please, any help will be apreciated.
Thanks.
What type of account are you using? Is this a corporate account or an MSA (live.com)?
I suppose corporate o365. Its one from the option of free 25 users for smbs at spain
I was able to run the sample and authenticate with my Microsoft corporate account, my @live.com account, and an account running on a test O365 tenant (@mod800621.onmicrosoft.com). Do you have an outlook.com or live.com account you could try? I'm wondering if there is something about your tenant specifically that is incompatible with the OAuth library.
Thanks jamescro. I have finally make this work with an tenant account. That were problems with my config password. With other corporate account I wasnt able to conect, but posible due to some prohibition in the company about give access to other apps.
Now I have trying to make work this inside a corporate intranet with ntlm proxy, but with no solution. Do you know how to make this work with ntlm request? I have tried modify graph_service.py with:
session = requests.Session()
proxies = {'http': 'http://myproxy:8080', 'https': 'http://myproxy:8080'}
session.proxies = proxies
proxy_auth = HttpNtlmAuth('my_domain\\my_user', 'my_pass')
session.auth = proxy_auth
response = session.post(url = send_mail_url, headers = headers, data = json.dumps(email), verify=False, params = None)
# Check if the response is 202 (success) or not (failure).
if (response.status_code == requests.codes.accepted):
return response.status_code
else:
return "{0}: {1}".format(response.status_code, response.text)
but seems that auth process fails on redirect to flask ... Maybe I have to modify some flask but I dont know what.
I don't know how to make this work with NTLM requests. This is really more of a question for the flask-oauth library. Could you post this as an issue there? This sample is more about using the Microsoft Graph API.
Closing for now. Please let me know if you need any help explaining the background for this when you post the issue to the flask-oauth library.
Thanks a lot jamescro. I have request for ntlm on oauth-flask at: https://github.com/lepture/flask-oauthlib/issues/326
I have been able to proceed with authorization with external cntlm.exe and make auth process with internal no-auth proxy @ localhost:3128.
The other code I exposed to send mail throught the ntlm proxy works fine (if anyone want to use).
Thanks. Feel free to share your work-around, either in this issue or in a fork.