没有不值得去解决的问题,也没有不值得去学习的技术!

Building a PC Authorization Link for a WeChat Third-Party Platform Triggers an Error: Authorization Entry Page Domain: Empty

When building a PC authorization link for a WeChat third-party platform, opening it directly throws an error: Error Please confirm that the domain of the authorization entry page is the same as the domain of the post-authorization callback page, and that both must be identical to the authorization initiation page domain filled in when applying for the third-party platform. Domain of the authorization entry page: empty.

1. When building a PC authorization link for a WeChat third-party platform, opening it directly throws an error: Error Please confirm that the domain of the authorization entry page is the same as the domain of the post-authorization callback page, and that both must be identical to the authorization initiation page domain filled in when applying for the third-party platform. Domain of the authorization entry page: empty. See Figure 1.

When building a PC authorization link for a WeChat third-party platform, opening it directly throws an error: Error Please confirm that the domain of the authorization entry page is the same as the domain of the post-authorization callback page, and that both must be identical to the authorization initiation page domain filled in when applying for the third-party platform. Domain of the authorization entry page: empty.
Figure 1

2. In the existing implemented program, opening the authorization entry page first and then redirecting to the PC authorization link does not throw an error, and the QR code to be scanned displays normally. Carefully comparing the differences between the two, the page that displays the QR code normally includes referer in its request headers. See Figure 2.

In the existing implemented program, opening the authorization entry page first and then redirecting to the PC authorization link does not throw an error, and the QR code to be scanned displays normally. Carefully comparing the differences between the two, the page that displays the QR code normally includes referer in its request headers.
Figure 2

3. Carefully comparing the differences between the two, the page that displays the QR code normally includes referer in its request headers. The page that throws the error does not include referer. See Figure 3.

Carefully comparing the differences between the two, the page that displays the QR code normally includes referer in its request headers. The page that throws the error does not include referer.
Figure 3

4. Official documentation: A third-party platform service provider builds an authorization link and places it on its own website; when a user clicks it, the authorization page pops up. I decided to place the PC authorization link under the authorization initiation page domain. I added the link at http://console.dev.chinamcloud.cn/ccpauth. See Figure 4.

Official documentation: A third-party platform service provider builds an authorization link and places it on its own website; when a user clicks it, the authorization page pops up. I decided to place the PC authorization link under the authorization initiation page domain. I added the link at http://console.dev.chinamcloud.cn/ccpauth.
Figure 4
HTML
<a href="https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=wxd98c58b273d21bdf&pre_auth_code=preauthcode@@@V8lWmb5dQYkVfJL8wUOKPWyN9ZMhT-n8cOz7B7xxHkqth3QPamJJpsbk5Q6lwgxs7y49-H_zefIjQdM8IECPVw&redirect_uri=https://console.dev.chinamcloud.cn/ccpauth&auth_type=1">PC端授权链接</a>

5. Right-click the PC authorization link and open it in a new tab. No error is thrown, the QR code to be scanned displays normally, and its request headers include referer. See Figure 5.

Right-click the PC authorization link and open it in a new tab. No error is thrown, the QR code to be scanned displays normally, and its request headers include referer.
Figure 5

6. View HTTP Headers -> Referer on MDN Web Docs. The Referer request header contains the address of the source page of the current request page, meaning the current page was accessed via a link from this source page. See Figure 6.

View HTTP Headers -> Referer on MDN Web Docs. The Referer request header contains the address of the source page of the current request page, meaning the current page was accessed via a link from this source page.
Figure 6

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系