# DiscourseConnect에서 사용자 지정 OAuth 검증을 사용하는 방법?

**URL:** https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808
**Category:** SSO
**Created:** [7월 10, 2024, 10:07오후 UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808 "2024-07-10T22:07:58Z")
**Posts on this page:** 5
**Page:** 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: [7월 10, 2024, 10:07오후 UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808/1 "2024-07-10T22:07:58Z")

</div>

현재 모든 것을 OAuth 방식으로 전환하는 작업의 한가운데 있습니다. Discourse는 제 목록에서 가장 마지막 순서입니다.

기능으로 추가될 수 있다면 완료하고 싶은 항목은 다음과 같습니다:

1. 사용자의 프로필 페이지에 표시할 공개/비공개 사용자 필드를 어떻게 생성하나요? 예를 들어, 누구나 볼 수 있는 `Group Rank`처럼, 또는 관리자 및 모더레이터(그리고 API)만 볼 수 있는 `Discord Id`처럼요.

또한, 이를 Python의 Quart를 사용하여 어떻게 구현할 수 있을까요? 제가 작성한 코드가 있지만, Discourse에 데이터를 전달하는 방법, 특히 사용자 필드를 포함하여 어떻게 전달해야 하는지, 그리고 사용자가 이를 편집하지 못하도록 만드는 방법에 대한 문서가 매우 불명확합니다.

```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),
        
        # 이 항목들은 사용자 필드(공개 또는 비공개)로 만들고 싶습니다
        "group_rank": group_rank, # 공개 사용자 필드
        "discord_id": discord_id, # 비공개 사용자 필드
        "roblox_id": roblox_info.user.id, # 비공개 사용자 필드
    }

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

```

---

<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: [7월 10, 2024, 10:12오후 UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808/2 "2024-07-10T22:12:53Z")

</div>

유저 필드라고 할 때, 유저 프로필 링크에 있는 이 항목을 의미합니다:  
 ![](https://global.discourse-cdn.com/meta/original/4X/2/1/b/21b441e84750121664f056b452758fbfb2f2a6a2.png)

---

<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: [7월 14, 2024, 3:00오전 UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808/4 "2024-07-14T03:00:24Z")

</div>

아직 도움이 필요해서 이 글을 올립니다.

---

<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: [7월 22, 2024, 4:28오후 UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808/5 "2024-07-22T16:28:13Z")

</div>

여전히 이 부분에 도움이 필요합니다. 아직 해결하지 못했습니다.

---

<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: [7월 23, 2024, 7:12오후 UTC](https://meta.discourse.org/t/how-to-use-custom-oauth-verification-with-discourseconnect/315808/6 "2024-07-23T19:12:42Z")

</div>

질문에 대한 업데이트:

1. URL을 base64로 인코딩해야 하나요, 아니면 인코딩하지 않고 그대로 사용해도 되나요?
2. 데이터를 반환하려면 어떻게 해야 하나요? 아래와 같은 형태인가요?

```py
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),
        
        # 이 필드들은 사용자 필드(공개 또는 비공개)로 설정하고 싶습니다.
        "group_rank": group_rank, # 공개 사용자 필드
        "discord_id": discord_id, # 비공개 사용자 필드
        "roblox_id": roblox_info.user.id, # 비공개 사용자 필드
    }

```
