# Access to privatized Wechat Mini program

The privatization applet is suitable for the following scenarios:

  • You need stronger brand customization capabilities, hoping to highlight your brand in the mini program.
  • You want to make the WeChat account of users who log in through the Mini Program scan the code to connect with their other WeChat public platforms (because the default Mini Program provided by Authing is associated with Authing's own WeChat subject, and obtained from your other WeChat public platforms unionid is not the same).

For details, please contact: [15559944612](tel: 15559944612).

The following is the specific access process of the privatized applet code:

# Configure the Mini Program ID in the console

Find Mini Program Scan Code Login in Connect Identity Source-Social Login:

Fill in the form with AppId and AppSecret:

Click save, then use authing-js-sdk

# Install authing-js-sdk

$ npm install authing-js-sdk --save

# Initialize authing-js-sdk

import { AuthenticationClient } from 'authing-js-sdk'
const authenticationClient = new AuthenticationClient({
  appId: 'YOUR_APP_ID',
})

# Call to open the mini program scan code login interface

const onScanningSuccess = async (userInfo: any, ticket: string) => {
  const { token } = userInfo
  if (!token) {
    // The polling interface will not return complete user information, you need to use a ticket in exchange
    userInfo = await client.exchangeUserInfo(ticket)
  }
}

authenticationClient.wxqrcode.startScanning('qrcode', {
  onSuccess: onScanningSuccess,
  onError: (message) => onFail && onFail(`${message}`),
})

After the user logs in, you can get the token from userinfo. This token is the user's identity credential. If you want to verify the legitimacy of the token on the backend, please refer to: Verify Token legitimacy.