# How to use custom OAuth verification with DiscourseConnect?

**URL:** <https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808>\
**Category:** SSO\
**Created:** [July 10, 2024, 10:07pm UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808 "2024-07-10T22:07:58Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![lawmixeraintalive](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lawmixeraintalive/32/199458_2.png) [@lawmixeraintalive](https://meta.discourse.org/u/lawmixeraintalive)\
**Post date:** [July 10, 2024, 10:07pm UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808/1 "2024-07-10T22:07:58Z")

</div>

I’m in the middle of trying to switch everything over to use my OAuth methods, and Discourse is the last thing on my list.

The things would love to complete if it is a feature:

1. How would I create public/private user fields to display in their user page about them? Like `Group Rank` for anybody to see, but like `Discord Id` for only admin and moderators can see (also API)?

Also, how would I implement this in python using Quart? This is some code that I programmed, though the documentation is very unclear on to pass data for Discourse and how too including User Fields, and trying to make them not so users can edit them.

```python
from quart import Quart, redirect, request
from rblxopencloud import OAuth2App, Group
from roblox import RobloxUser

oauth_app = OAuth2App("ROBLOX_APP_ID", "ROBLOX_APP_SECRET", "ROBLOX_APP_REDIRECT")
app = Quart( __name__ )
    
@app.route("/")
async def authentication_verify():
    return redirect(oauth_app.generate_uri(["openid", "profile"]))

@app.route("/authentication/redirect")
async def authentication_redirect():
    roblox_info = oauth_app.exchange_code(request.args.get('code'))
    
    group_member: Group = RobloxUser.fetch_member(roblox_info.user, 4800717)
    group_rank = "Test Subject"
    
    if group_member != None:
        group_rank = group_member.fetch_role().name
    
    
    discord_id = "this-will-pull-from-my-db"
    
    return {
        "permalink": roblox_info.user.username,
        "username": roblox_info.user.username, 
        "uri": roblox_info.user.profile_uri, 
        "avatar_url": roblox_info.user.generate_headshot(size=420, format="jpeg", is_circular=True),
        
        # These I would like to be user fields (either public or private)
        "group_rank": group_rank, # Public User Field
        "discord_id": discord_id, # Private User Field
        "roblox_id": roblox_info.user.id, # Private User Field
    }

app.run(host="host-ip-here", port=0000)

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808)._
