Hello everyone!
So we were developing a mini website for some mini project, then we decided to have a profile edit page. I checked out and came out with this code:
def auth0_user_profile(request):
session_data = request.session.get('session_id')
id_token = session_data.get('id_token') if session_data else None
if id_token:
jwk_set = oauth.auth0.fetch_jwk_set()
user_data = jwt.decode(id_token, jwk_set)
user_id = user_data.get('sub')
if user_id:
#auth0_profile_url = f"https://OURTENANTNAME.auth0.com/userinfo?user_id={user_id}"
auth0_profile_url = f"https://settings.cageda.auth0.com/userinfo?user_id={user_id}"
return redirect(auth0_profile_url)
else:
messages.error(request, 'Unable to access profile page.')
This is written in ‘views.py’ - default file in Django development. Also, I added the corresponding url to ‘urls.py’ as
path(‘profile/’, views.auth0_user_profile, name=‘auth0_user_profile’),
However, when I click the button assigned for this function, I see an error as
URIError: Failed to decode param '/%7B%%20url%20'auth0_user_profile'%20%%7D'
at decodeURIComponent (<anonymous>)
at decode_param (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\layer.js:172:12)
at Layer.match (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\layer.js:123:27)
at matchLayer (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\index.js:585:18)
at next (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\index.js:226:15)
at expressInit (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\index.js:328:13)
at C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\index.js:286:9
at Function.process_params (C:\Users\MYCOMPUTER\Desktop\PROJECT\frontend-app\node_modules\express\lib\router\index.js:346:12)
So, how can I solve this and redirect my users to their corresponding profile page in Auth0 domain? Is it possible, right?