# Assistance Required with GL.iNet Router Authentication API

**URL:** <https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772>\
**Category:** Router\
**Created:** [October 28, 2024, 5:57pm UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772 "2024-10-28T17:57:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fahadbaig34](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/fahadbaig34/32/21487_2.png) [@fahadbaig34](https://forum.gl-inet.com/u/fahadbaig34)\
**Post date:** [October 28, 2024, 5:57pm UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/1 "2024-10-28T17:57:45Z")

</div>

Dear GL.iNet Support Team,

We are working with a GL.iNet router running firmware version 4.5.17 and attempting to connect to it through our mobile application, which is intended for IoT device communication.

We are currently using the following API calls for authentication:

1. **Challenge Request**

bash curl -X POST [http://192.168.8.1/rpc](http://192.168.8.1/rpc) -d '{"jsonrpc":"2.0","id":1,"method":"challenge","params":{"username":"root"}}'

1. **Login Request**

bash

curl '[http://192.168.8.1/rpc](http://192.168.8.1/rpc)' \

```auto
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Origin: http://192.168.8.1' \
  -H 'Referer: http://192.168.8.1/' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \
  --data-raw '{"jsonrpc":"2.0","id":2,"method":"login","params":{"username":"root","hash":"0f14baf69fa5420c7ed0e7d0643c9cb5"}}' \
  --insecure

```

Despite using these endpoints, we are receiving the following error:

{"id":2,"jsonrpc":"2.0","error":{"message":"Access denied","code":-32000}}

We have reviewed the documentation provided at: [GL.iNet HTTP RESTful API Documentation](https://docs.gl-inet.com/iot/en/thread_board_router/gl-s20/user_manual/apis/http_restful_api/#/ui/challenge), but unfortunately, it hasn’t resolved the issue.

Could you please provide any updated documentation, guidance, or examples on how to successfully authenticate using these APIs?

Thank you very much for your assistance, and we look forward to your response.

best,  
Fahad Baig  
Technical Lead Manager

> **[Tepia: Orange County Mobile App Developers](https://tepia.co)**
>
> Tepia is a Orange County based web and mobile app development team. We build mobile apps, enterprise web applications, and custom websites or e-commerce sites.

---

<div class="post-metadata">

**Author:** ![Quidn](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/q/439d5e/32.png) [@Quidn](https://forum.gl-inet.com/u/Quidn)\
**Post date:** [October 28, 2024, 6:21pm UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/2 "2024-10-28T18:21:02Z")

</div>

My first thought when I started reading your post was, 'how the hash was generated?'.

> [@fahadbaig34](#):
>
> We have reviewed the documentation provided at: [GL.iNet HTTP RESTful API Documentation](https://docs.gl-inet.com/iot/en/thread_board_router/gl-s20/user_manual/apis/http_restful_api/#/ui/challenge), but unfortunately, it hasn’t resolved the issue.

And this is exactly the problem. That's not router API documentation and actually the router API uses a different hash algorithm.

If you trace the browser request, you will find that the router API uses the [unixpass library](https://www.npmjs.com/package/unixpass). Not HmacSHA256.

---

<div class="post-metadata">

**Author:** ![admon](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/admon/32/32880_2.png) [@admon](https://forum.gl-inet.com/u/admon)\
**Post date:** [October 28, 2024, 6:51pm UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/3 "2024-10-28T18:51:31Z")

</div>

I recommend to run Burp Suite to catch all requests: [Download Burp Suite Community Edition - PortSwigger](https://portswigger.net/burp/communitydownload)

There is no official API documentation anymore and I highly doubt it will come back.

---

<div class="post-metadata">

**Author:** ![fahadbaig34](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/fahadbaig34/32/21487_2.png) [@fahadbaig34](https://forum.gl-inet.com/u/fahadbaig34)\
**Post date:** [October 28, 2024, 7:29pm UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/4 "2024-10-28T19:29:22Z")

</div>

Thanks Quidn. I am working in Swift language. Can you share a swift example to generate hash with salt, nonce and alg using username and password of the router? Would be a huge help.

---

<div class="post-metadata">

**Author:** ![Quidn](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/q/439d5e/32.png) [@Quidn](https://forum.gl-inet.com/u/Quidn)\
**Post date:** [October 28, 2024, 8:47pm UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/5 "2024-10-28T20:47:34Z")

</div>

> [@fahadbaig34](#):
>
> Thanks Quidn. I am working in Swift language. Can you share a swift example to generate hash with salt, nonce and alg using username and password of the router? Would be a huge help.

I know nothing about Swift, but aren't there a built-in function or libraries?  
Also `openssl passwd` will do the same thing.  
It's pretty common, but yeah usually needs polyfills nowadays.

---

<div class="post-metadata">

**Author:** ![fahadbaig34](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/fahadbaig34/32/21487_2.png) [@fahadbaig34](https://forum.gl-inet.com/u/fahadbaig34)\
**Post date:** [October 29, 2024, 5:11pm UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/6 "2024-10-29T17:11:47Z")

</div>

I have found the below algorithm in which Hash is being produced but we are not able to replicate it in python or swift:

```auto
methods: {
          async handleLogin() {
            if (this.isLoading) return;
            (await this.$refs.loginForm.validate()) &&
              ((this.isLoading = !0),
              c.challenge({ username: this.form.username }).then(
                (t) => {
                  if (!t || !t.err_msg) {
                    const { alg: e, nonce: r, salt: n } = t,
                      o = this.$up.crypt(this.form.password, ⁠ $${e}$${n}$ ⁠),
                      i = this.$md5(this.form.username + ":" + o + ":" + r);
                    this.login({ username: this.form.username, hash: i });
                  }
                },
                (t) => {
                  this.isLoading = !1;
                  const e = JSON.parse(t);
                  "Login fail number over limit" === e.error.message &&
                    (this.$message.closeAll(),
                    this.$message.error(
                      this.$t("login.retry_after").replace(
                        "$$$$",
                        e.error.data.wait,
                      ),
                    ));
                },
              ));
          },
          login(t) {
            c.login(t)
              .then((t) => {
                (this.isLoading = !1),
                  (t && t.err_msg) ||
                    this.$loadMenuRoute().then(() => {
                      this.$route.params.goBack &&
                      "process" !== this.$route.params.goBack
                        ? this.$router.replace({
                            name: this.$route.params.goBack,
                          })
                        : this.$router.replace({ name: "internet" });
                    });
              })
              .catch((t) => {
                this.isLoading = !1;
                "Access denied" === JSON.parse(t).error.message &&
                  (this.$message.closeAll(),
                  this.$message.error(this.$t("login.err_msg")));
              });
          },
```

---

<div class="post-metadata">

**Author:** ![Quidn](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/q/439d5e/32.png) [@Quidn](https://forum.gl-inet.com/u/Quidn)\
**Post date:** [October 30, 2024, 7:18am UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/8 "2024-10-30T07:18:18Z")

</div>

> [@Quidn](#):
>
> If you trace the browser request, you will find that the router API uses the [unixpass library](https://www.npmjs.com/package/unixpass). Not HmacSHA256.

> Also `openssl passwd` will do the same thing.

As I said,

- Basically it's same as the IoT API, but `up.crypt` rather than the `CryptoJS.HmacSHA256`.
- The `up.crypt`([unixpass](https://www.npmjs.com/package/unixpass)) results standard Unix-compatible password hash, also `openssl passwd`([doc](https://docs.openssl.org/master/man1/openssl-passwd/)) will do the same.

> [@fahadbaig34](#):
>
> ```auto
> const { alg: e, nonce: r, salt: n } = t,
> o = this.$up.crypt(this.form.password, ⁠ $${e}$${n}$ ⁠),
> i = this.$md5(this.form.username + ":" + o + ":" + r);
> this.login({ username: this.form.username, hash: i });
> 
> ```

And what you found is proving it.

> [@Quidn](#):
>
> I know nothing about Swift

I know how to mimic that with JavaScript([unixpass](https://www.npmjs.com/package/unixpass)), PHP([crypt](https://www.php.net/manual/function.crypt.php)), and shell script([openssl](https://docs.openssl.org/master/man1/openssl-passwd/)), but no idea with Swift or Python.

> [@Quidn](#):
>
> aren't there a built-in function or libraries?

However it seems there are solutions for Python including built-in one:

- [crypt — Function to check Unix passwords — Python 3.9.20 documentation](https://docs.python.org/3.9/library/crypt.html)
- [hashlib — Secure hashes and message digests — Python 3.13.0 documentation](https://docs.python.org/3.13/library/hashlib.html#module-hashlib)
- [passlib · PyPI](https://pypi.org/project/passlib/)

And also for Swift:

- [GitHub - jedisct1/swift-sodium: Safe and easy to use crypto for iOS and macOS](https://github.com/jedisct1/swift-sodium)

I don't know if those will work but you will find a solution in any way.

---

<div class="post-metadata">

**Author:** ![system](https://forum-static.gl-inet.com/original/3X/7/7/77e28f6cb342ac4bd641bd9a6254595d61b2812a.png) [@system](https://forum.gl-inet.com/u/system)\
**Post date:** [April 28, 2025, 7:18am UTC](https://forum.gl-inet.com/t/assistance-required-with-gl-inet-router-authentication-api/49772/9 "2025-04-28T07:18:41Z")

</div>

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