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

Flask redirect uri #442

Closed vawogbemi closed 4 years ago

vawogbemi commented 4 years ago

When I use my absolute uri for step 2 i.e http://127.0.0.1:5000/steptwo I get this error

We're unable to complete your request invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application.

Then when I replace request uri with the registered uri in the azure app the screen doesn't load and I get some scope errors in the uri box i.e

https://login.microsoftonline.com/common/oauth2/nativeclient?error=invalid_scope&error_description=The%20provided%20value%20for%20the%20input%20parameter%20%27scope%27%20is%20not%20valid.%20The%20scope%20%27https://graph.microsoft.com/Mail.ReadWrite%20https://graph.microsoft.com/Mail.Send%20https://graph.microsoft.com/Offline.Access%20https://graph.microsoft.com/User.Read%27%20does%20not%20exist.&state=R0epKg06vBim3wdfjjfR0HtX2rFeNg

alejcas commented 4 years ago

I think this has nothing to do with this library.

If you registered a given url, then you should always use the same url.

vawogbemi commented 4 years ago

Thanks, didn't realize I had to register local host too, now I've got it working

mohanrkrishna commented 4 years ago

Hi @victorawogbemi - Could you please share sample flask O365 code. I am trying to implement , new to python flask. Not clear on best way to store state and how to use FIlebackendtoken from O365 package. Appreciate your help

vawogbemi commented 4 years ago

@mohanrkrishna

https://github.com/victorawogbemi/hypemail/blob/master/hypemail.py

for the token storage I copied this https://github.com/O365/python-o365/issues/370

add https://localhost:portnumber to redirect uris in the azure console for you app

you need a https so to run on localhost so I installed pyopenssl and used this flask run --cert adhoc -host=localhost

mohanrkrishna commented 4 years ago

Thanks very much @victorawogbemi Appreciate your help!