I'm using identity==0.9.2. I'm using below code to create login authentication for Microsoft. While using identity.web.auth.get_user() method to get the current login user info, I'm getting the None response from it. If I refresh the page after a few seconds, it works fine.
Code
from identity.web import Auth
AUTH = Auth(session=session, authority=secrets['ms_graph']['common']['AUTHORITY'], client_id=secrets['ms_graph'][location]['CLIENT_ID'], client_credential=secrets['ms_graph'][location]['CLIENT_SECRET'])
...
resp = AUTH.complete_log_in(request.args)
if "error" in resp:
return redirect(f"/login_error")
result = AUTH.get_user()
location = result['preferred_username'].split("@")[1].split('.')[0]
I'm getting below error:
ERROR in app: Exception on /getAToken [GET]
Traceback (most recent call last):
File "/DCoE/.virtualenvs/Launch_Pad/lib/python3.12/site-packages/flask/app.py", line 1511, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/DCoE/.virtualenvs/Launch_Pad/lib/python3.12/site-packages/flask/app.py", line 919, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/DCoE/.virtualenvs/Launch_Pad/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/DCoE/.virtualenvs/Launch_Pad/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/DCoE/Production/Launch-Pad/launch_pad.py", line 91, in resp_auth
location = result['preferred_username'].split("@")[1].split('.')[0]
~~~~~~^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
I'm using
identity==0.9.2. I'm using below code to create login authentication for Microsoft. While usingidentity.web.auth.get_user()method to get the current login user info, I'm getting theNoneresponse from it. If I refresh the page after a few seconds, it works fine.Code
I'm getting below error: