How to Configure WeChat OAuth Authentication for Captive Portals
This technical guide explains how to configure WeChat OAuth authentication for captive portals. It details the required platform registrations, OAuth 2.0 flow, scope selection, and network enforcement mechanisms necessary to capture first-party data from Chinese visitors securely.
Listen to this guide
View podcast transcript
- Executive Summary
- Technical Architecture
- Platform Registration Requirements
- WeChat Official Accounts Platform
- WeChat Open Platform
- Scope Selection and Data Collection
- snsapi_base
- snsapi_userinfo
- Network Enforcement Integration
- RADIUS Change of Authorisation (CoA)
- MAC Address Bypass
- Compliance and Security Considerations
- GDPR and PIPL Alignment
- CSRF Protection
- Redirect URI Validation

Executive Summary
When Chinese visitors connect to your WiFi, presenting a login page with only email or Facebook creates immediate friction. WeChat has 1.38 billion monthly active users, and configuring it as an identity provider eliminates this barrier. This guide explains how to implement WeChat OAuth 2.0 authentication for captive portals, detailing the necessary platform registrations, the OAuth flow, and the network enforcement mechanisms required to translate a successful login into network access. We cover the technical implementation across enterprise hardware and the compliance requirements under GDPR and PIPL.
Technical Architecture
A captive portal intercepts HTTP traffic from an unauthenticated device and redirects it to a login page hosted on a portal server. When you integrate WeChat OAuth, you insert a third-party identity provider into this flow.

The sequence operates as follows:
- The visitor connects to the SSID.
- The access point or wireless controller detects the lack of an authenticated session and redirects HTTP traffic to the captive portal URL.
- The visitor selects WeChat login.
- The portal server redirects the browser to WeChat's authorisation endpoint (
open.weixin.qq.com), passing theAppID,redirect_uri,response_type=code, andscope. - WeChat handles authentication. If the visitor uses the WeChat in-app browser with
snsapi_basescope, this occurs silently. - WeChat redirects back to the portal's
redirect_uriwith a temporary authorisation code. - The portal server exchanges this code for an access token by calling
api.weixin.qq.com/sns/oauth2/access_token. - WeChat returns an
access_token,refresh_token, and the user'sopenid.
Platform Registration Requirements
Implementing WeChat login requires registration on the correct developer platform. WeChat operates two distinct platforms, and selecting the wrong one causes the integration to fail.
WeChat Official Accounts Platform
For a captive portal serving visitors inside the WeChat in-app browser, you require a Service Account on the Official Accounts Platform (mp.weixin.qq.com). A Subscription Account lacks the necessary OAuth web page authorisation permissions. A Service Account supports both snsapi_base and snsapi_userinfo scopes.
WeChat Open Platform
For a captive portal accessed from a standard mobile browser outside WeChat (such as Chrome on Android or Safari on iOS), you require a Website Application registered on the Open Platform (open.weixin.qq.com). This uses the snsapi_login scope and presents a QR code that the user scans with their WeChat app.
Most enterprise deployments require both registrations to cover all access methods.
Scope Selection and Data Collection
The scope parameter determines what data WeChat returns to your portal server. This decision impacts both user friction and data privacy compliance.

snsapi_base
This scope returns only the OpenID, a unique identifier for the user within your Official Account. It requires no user consent prompt, making the authentication invisible to the user. This is optimal for returning visitors where you already hold a profile, or for venues prioritising zero friction over new data collection.
snsapi_userinfo
This scope returns the OpenID plus the user's WeChat nickname, profile picture, gender, language setting, and city. It requires an explicit consent screen, introducing friction. Use this for first-time visitor registration where building a profile is necessary, paired with a GDPR-compliant consent layer.
Network Enforcement Integration
Acquiring an OAuth token proves identity, but it does not open the network. You must translate a successful authentication into network access using standard protocols.
RADIUS Change of Authorisation (CoA)
Defined in IEEE 802.1X and RFC 3576, RADIUS CoA allows the portal server to send a request to the network controller after successful OAuth. The controller then moves the device from the unauthenticated VLAN to the guest VLAN. This is the standard for enterprise hardware including Cisco Meraki, HPE Aruba, Ruckus, and Juniper Mist.
MAC Address Bypass
Alternatively, the portal server registers the device's MAC address as an authorised client, and the controller allows it. While simpler to implement, it is less secure as MAC addresses can be spoofed.
Purple's cloud overlay automates this translation, sending the appropriate signal to the underlying hardware (including Ubiquiti UniFi, Cambium, Extreme, and Fortinet) once WeChat OAuth completes.
Compliance and Security Considerations
GDPR and PIPL Alignment
If you serve European visitors, GDPR applies to the data collected via WeChat OAuth. If you serve Chinese visitors, China's Personal Information Protection Law (PIPL) applies. Both frameworks require a lawful basis for processing, clear purpose limitation, and data minimisation. The snsapi_base scope aligns more easily with data minimisation principles than snsapi_userinfo.
CSRF Protection
The state parameter in the OAuth request prevents cross-site request forgery. You must generate a cryptographically random state value, store it in the user's session, and validate it when WeChat redirects back.
Redirect URI Validation
WeChat validates the redirect_uri against the authorised domain registered on the platform. If your portal server uses a different subdomain, path, or HTTP instead of HTTPS, the OAuth flow fails with error 40029.
For more information on securing your network, see our Enterprise WiFi Security: A Complete Guide for 2026 .
Key Definitions
snsapi_base
A WeChat OAuth scope that returns only the user's OpenID without displaying a consent prompt.
Used when IT teams need to authenticate returning visitors silently without causing login friction.
snsapi_userinfo
A WeChat OAuth scope that returns the OpenID along with demographic data (nickname, gender, city) and requires explicit user consent.
Used during first-time registration when marketing teams need to build a visitor profile.
OpenID
A unique identifier for a specific user within a specific WeChat Official Account.
Used as the primary key in the portal database to track visitor behaviour and return visits.
RADIUS CoA
Change of Authorisation. A mechanism defined in RFC 3576 that allows a server to modify the authorisation state of an active session.
Used by the portal server to tell the wireless controller to grant network access after successful WeChat authentication.
PIPL
Personal Information Protection Law. China's comprehensive data privacy regulation.
Must be considered alongside GDPR when designing the consent flow for Chinese visitors using WeChat login.
AppID and AppSecret
The credentials provided by WeChat to identify and authenticate your application.
The AppSecret must remain securely on the portal server and never be exposed in client-side code.
State Parameter
A cryptographically random string passed in the OAuth request and validated upon return.
Essential for preventing Cross-Site Request Forgery (CSRF) attacks on the captive portal.
MAC Address Bypass
A method of granting network access by authorising the device's hardware address rather than requiring 802.1X authentication.
An alternative to RADIUS CoA for simpler network setups, though less secure.
Worked Examples
A luxury retail brand in London wants to offer WeChat login for Chinese shoppers. They want to collect demographic data to understand their customer base, but they are concerned about GDPR compliance and high drop-off rates at the portal.
The retailer should register a Service Account on the WeChat Official Accounts Platform. They must configure the portal to use the snsapi_userinfo scope for first-time connections to gather demographic data (nickname, gender, city). To ensure GDPR compliance, the portal page must display a clear, conscious-choice opt-in before the WeChat redirect, explaining exactly what data is collected and why. For returning shoppers, the portal should detect the MAC address and use snsapi_base for silent re-authentication, minimising friction.
A stadium deploys a new WiFi network using HPE Aruba controllers. They have configured WeChat OAuth, and the portal successfully receives the access token, but the visitor's device remains on the captive portal page and cannot access the internet.
The integration lacks a network enforcement mechanism. The portal server has verified the user's identity with WeChat, but it has not instructed the HPE Aruba controller to grant access. The portal server must be configured to send a RADIUS Change of Authorisation (CoA) message to the controller, instructing it to transition the user's MAC address from the pre-authentication role to the authenticated guest role.
Practice Questions
Q1. You are deploying a captive portal across a retail chain. Testing shows that users opening the portal in Safari on iOS receive an error when selecting WeChat login, but users opening the portal from within a WeChat message link authenticate successfully. What is the likely cause?
Hint: Consider the difference between the WeChat in-app browser and standard mobile browsers.
View model answer
The implementation is likely relying solely on a Service Account registered on the Official Accounts Platform, which only supports OAuth within the WeChat in-app browser. To support Safari on iOS, you must also register a Website Application on the WeChat Open Platform and implement user agent detection to route Safari users to the QR code flow.
Q2. Your portal server logs show frequent 40029 'invalid code' errors returning from the WeChat API during the access token exchange. What configuration should you check first?
Hint: Think about how WeChat validates the source of the authentication request.
View model answer
You should verify the redirect_uri configuration. WeChat strictly validates the redirect URI against the authorised domain registered in the developer console. If the portal is using a different subdomain, or if it drops HTTPS, WeChat will reject the code exchange.
Q3. A venue operator wants to collect visitor data but insists on zero friction during the login process. They request that you configure WeChat login to collect the visitor's nickname and city without showing a consent prompt. How do you respond?
Hint: Review the capabilities of the different OAuth scopes.
View model answer
You must inform the operator that this is technically impossible. Collecting demographic data like nickname and city requires the snsapi_userinfo scope, which mandatorily triggers a WeChat consent prompt. To achieve zero friction, you must use snsapi_base, which operates silently but only returns the OpenID.
Continue reading in this series
Measuring the Business ROI of Guest WiFi and Location Analytics
This guide provides a technical and operational framework for measuring the business ROI of guest WiFi and location analytics. It details how to calculate value from hardware investments through dwell time uplift, operational efficiency, and first-party data capture across retail, hospitality, and public venues. IT managers, network architects, CTOs, and venue operations directors will find concrete measurement frameworks, real-world case studies, and compliance guidance to justify and maximise their WiFi investment.
Integrating WeChat WiFi Login: Capturing Engagement via Social Captive Portals
This guide details how to integrate WeChat WiFi authentication into enterprise captive portals, covering the OAuth 2.0 architecture, RADIUS integration, and step-by-step deployment across Cisco Meraki, HPE Aruba, and Juniper Mist hardware. It gives IT managers and network architects a practical framework for capturing first-party data from WeChat's 1.3 billion users while driving engagement via Official Account follows and post-login redirects.
WiFi GDPR Compliance: How to Securely Collect Guest Data via Captive Portals
This technical guide gives IT managers, network architects, and venue operations directors a practical framework for achieving GDPR compliance across guest WiFi deployments. It covers how captive portals collect personal data, how to secure explicit consent, and how to implement automated data retention policies that protect your organisation from regulatory fines of up to 4% of global turnover. Purple's guest WiFi platform maps directly to each compliance requirement, from consent logging to one-click data erasure.