# Unicode usernames

**URL:** https://meta.discourse.org/t/unicode-usernames/277878
**Category:** Development
**Tags:** rest-api
**Created:** [September 5, 2023, 4:50pm UTC](https://meta.discourse.org/t/unicode-usernames/277878 "2023-09-05T16:50:44Z")
**Posts on this page:** 9
**Page:** 2

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [September 11, 2023, 2:03am UTC](https://meta.discourse.org/t/unicode-usernames/277878/25 "2023-09-11T02:03:36Z")

</div>

> [@supermathie](#):
>
> Does the same call with an ASCII username work?

The answer is yes.  
It seems that only non-latin usernames have problems in my case.

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/e/4/9e4b00d42250baba50fd1f9ba8940112b91bed69.jpeg)

(This api\_key was immediately revoked by me, so there is no problem with leaking it.)

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [September 11, 2023, 2:29am UTC](https://meta.discourse.org/t/unicode-usernames/277878/26 "2023-09-11T02:29:18Z")

</div>

I’m curious to know if this particular site is installed in a different manner, perhaps another proxy in front of it?

---

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [September 11, 2023, 2:36am UTC](https://meta.discourse.org/t/unicode-usernames/277878/27 "2023-09-11T02:36:08Z")

</div>

It is indeed behind the proxy. I’m not sure, maybe that had an impact?

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [September 11, 2023, 2:44am UTC](https://meta.discourse.org/t/unicode-usernames/277878/28 "2023-09-11T02:44:11Z")

</div>

I suspect the proxy may be the cause.

Can you send the request direct to the real server’s IP and see what result you get back?

That’ll let us know if it’s Cloudflare interfering.

---

<div class="post-metadata">

### Author: ![xFocus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xfocus/32/463960_2.png) [@xFocus](https://meta.discourse.org/u/xFocus)
#### Post date: [November 28, 2024, 3:13pm UTC](https://meta.discourse.org/t/unicode-usernames/277878/29 "2024-11-28T15:13:49Z")

</div>

I tried and seems not working for me either

if applying `.encode()` to the chinese characters username, or `urllib.parse.quote()`

```plaintext
    headers = {
        'Api-Key': API_KEY,
        'Api-Username': '大帅哥'.encode()
    }

    # or urllib parse
    headers = {
        'Api-Key': API_KEY,
        'Api-Username': urllib.parse.quote(API_USERNAME)
    }

```

I will get error

```plaintext
Failed to create post. Status code: 403
{'errors': ['您没有权限查看请求的资源。API 用户名或者密钥无效。'], 'error_type': 'invalid_access'}

```

but, without `.encode()`

```plaintext
    headers = {
        'Api-Key': API_KEY,
        'Api-Username': '大帅哥'
    }

```

I will get error

```plaintext
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256)

```

---

<div class="post-metadata">

### Author: ![xFocus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xfocus/32/463960_2.png) [@xFocus](https://meta.discourse.org/u/xFocus)
#### Post date: [November 28, 2024, 3:19pm UTC](https://meta.discourse.org/t/unicode-usernames/277878/30 "2024-11-28T15:19:04Z")

</div>

also tried to create user name just use the encoded string `"username": "\xe5\xa4\xa7\xe5\xb8\x85\xe5\x93\xa5"`, but seems not working either as it’s not decoded properly I guess

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [November 28, 2024, 10:30pm UTC](https://meta.discourse.org/t/unicode-usernames/277878/31 "2024-11-28T22:30:42Z")

</div>

What language and language version?

---

<div class="post-metadata">

### Author: ![xFocus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xfocus/32/463960_2.png) [@xFocus](https://meta.discourse.org/u/xFocus)
#### Post date: [November 29, 2024, 3:07pm UTC](https://meta.discourse.org/t/unicode-usernames/277878/32 "2024-11-29T15:07:46Z")

</div>

it’s chinese characters  
not sure how to check the language version tho…  
thanks Michael

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [November 29, 2024, 5:53pm UTC](https://meta.discourse.org/t/unicode-usernames/277878/33 "2024-11-29T17:53:11Z")

</div>

Those questions were about the _programming_ language 😃

[Previous page](https://meta.discourse.org/t/unicode-usernames/277878.md?page=1)
