# Redirect users to Auth0 profile edit page

**URL:** <https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [December 21, 2023, 7:10pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513 "2023-12-21T19:10:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zedeleyici](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zedeleyici/32/49217_2.png) [@zedeleyici](https://community.auth0.com/u/zedeleyici)\
**Post date:** [December 21, 2023, 7:10pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513/1 "2023-12-21T19:10:27Z")

</div>

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:

```auto
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

```auto
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?

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [December 21, 2023, 7:35pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513/2 "2023-12-21T19:35:06Z")

</div>

Hi @zedeleyici

Welcome to the Auth0 Community!

Thank you for posting your question. It looks like there is a problem with URL encoding. Can you check (print, for example) the content of the `jwt` before it has been decoded (I assume this function raises this error)? When you capture the JWT you can check to content on the [jwt.io](http://jwt.io) website.

Dawid

---

<div class="post-metadata">

**Author:** ![zedeleyici](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zedeleyici/32/49217_2.png) [@zedeleyici](https://community.auth0.com/u/zedeleyici)\
**Post date:** [December 21, 2023, 7:57pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513/4 "2023-12-21T19:57:34Z")

</div>

Additional note: I used the same jwk\_set to check email verification 1 month ago as:

```
id_token = token.get('id_token')
jwk_set = oauth.auth0.fetch_jwk_set()
user_info = jwt.decode(id_token, jwk_set)

if not user_info.get('email_verified'):
    messages.error(request, 'You must verify your email to log in.')
    return redirect('http://localhost:3000/callback')

```

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [December 21, 2023, 8:08pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513/5 "2023-12-21T20:08:41Z")

</div>

`JWK_SET` is a JSON Web Key Set and it is a set of keys containing the public keys used to verify any JSON Web Token (JWT) issued by the Authorization Server and signed using the RS256.

I’ve double-checked the Authentication API and the proper way to get /userinfo is via ACCESS\_TOKEN in the Header ‘Authorization: Bearer {ACCESS\_TOKEN}’ you may need to adjust your code for that [https://auth0.com/docs/api/authentication#get-user-info](https://auth0.com/docs/api/authentication#get-user-info)

---

<div class="post-metadata">

**Author:** ![zedeleyici](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zedeleyici/32/49217_2.png) [@zedeleyici](https://community.auth0.com/u/zedeleyici)\
**Post date:** [December 21, 2023, 8:15pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513/6 "2023-12-21T20:15:14Z")

</div>

Yes but this does not help me about redirecting the user-corresponding profile page for users to edit their pages, without any action from the administrator. I see the point, but still, I need user\_id for the url part of my code, yet still don’t have with this information. So, maybe I can’t see the point but this is what I think. Sorry:(

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [December 21, 2023, 8:56pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513/7 "2023-12-21T20:56:58Z")

</div>

The topic has been discussed in the DMs.

The answer to the original question is that there’s no premade by Auth0 separated page for editing user profiles. The best way to achieve this is to fetch the details from the /userinfo endpoint, show them to the user, and update them by calling Management API to update a user profile.

[Auth0 Management API v2](https://auth0.com/docs/api/management/v2/users/patch-users-by-id)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 4, 2024, 8:57pm UTC](https://community.auth0.com/t/redirect-users-to-auth0-profile-edit-page/123513/8 "2024-01-04T20:57:24Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
