Authing DocsDocuments
Concept
workflow
Guides
Development Integration
Application integration
Concept
workflow
Guides
Development Integration
Application integration
Old Version
Guides
  • Quick start

  • Authenticate the user

  • Authority management for users

  • Authorization

  • Manage user accounts

  • Manage User Directory

  • Management Application

  • Become a source of federal authentication identity

  • Connect to an external identity provider (IdP)

  • Open up WeChat ecology
  • Migrate users to Authing

  • Management organization

  • Expandable capabilities

  • Audit Log

  • Configure security information

  • Configure user pool information

  • Deployment plan

  • Frequently Asked Questions FAQs

¶ Mobile app Use WeChat Login

Update Time: 2025-05-14 08:32:28
Edit

Authing Providing developers with a way to quickly jump WeChat login to obtain user information in the mobile terminal (iOS or Android) application, Simple call Authing mobile SDK can complete WeChat account access.

  • Application scenario: mobile APP;
  • Overview: Pull up the WeChat APP in the mobile application to log in;
  • View WeChat official document (opens new window)

¶ Step 1: Create a WeChat mobile app on the WeChat open platform

Please go to WeChat open platform (opens new window)Guide Create a WeChat mobile app, you need to record the App ID and App secret of the app, will be used later.

¶ Step 2: Configure WeChat mobile app on Authing console

In the console's social login configuration page, find the WeChat mobile app, fill in the following configuration:

  • AppID: WeChat mobile app ID;
  • AppSecret: WeChat mobile application key.

Click "OK" to save information after the configuration is complete.

¶ Step 3: Start development access

¶ Configure iOS Universal Links

Starting from WeChat WeChatopensdk 1.8.6, iOS mobile apps need to fill in Universal Links information. If you want to develop Android applications or have been configured, you can skip this section.

¶ Configure apple-app-site-association file

In the Apple Developer Console Membership page finds your own Team ID:

In Xcode Targets -> Signing & Capabilities find Bundle Identifier:

Next to create apple-app-site-association file:

if your Team ID is xxxxxxx, Bundle Identifier is com.example.exampleApp, set Universal Link Path is /native/*, apple-app-site-association such as:

if your Team ID is xxxxxxx, Bundle Identifier is com.example.exampleApp, set Universal Link Path is /native/*, apple-app-site-association such as:

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appIDs": ["xxxxxxx.com.example.exampleApp"],
        "paths": ["/native/*"]
      }
    ]
  }
}

You need to deploy this file to your domain name .well-known/apple-app-site-association link, such as your domain name example.com,It is necessary to pass https://example.com/.well-known/apple-app-site-association Access to this file. The following points need to pay attention:

  • must use https
  • apple-app-site-association need to be a legitimate JSON file, but no .json。
  • content-type need to be set to application/json
  • paths please use * wildcard, WeChat requirements.

The following is an nginx configuration example: (here you put the apple-app-site-association file with a .well-known folder)

server {
  listen 80;
  listen 443 ssl;

  server_name authing.cn;

  ssl_certificate /mnt/cerm/client/1_authing.cn_bundle.crt;
  ssl_certificate_key /mnt/cerm/client/2_authing.cn.key;
  ssl_session_timeout 5m;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;


  location /.well-known {
    alias /path/to/your/.well-known/folder;
    try_files $uri $uri/ =404;
  }
}

¶ In Xcode configure Associated Domains

Add down to configure Associated Domains in Xcode. In Xcode Targets -> Signing & Capabilities Page click on the upper right corner +Capability :

select Associated Domains:

Suppose your domain name is example.com, fill in applinks:example.com :

¶ Verify Universal Links takes effect

Suppose your domain name example.com,Path is /native/* After installing your app on your phone, use Safari browser Access https://example.com/native/, Pull the webpage online, you should be able to see your app:

Visit again https://example.com/native/xxx, It can still be seen.

¶ Fill in the WeChat open platform Universal Links

¶ Access WechatOpenSDK

Please follow WeChat official document (opens new window)Guide access WechatOpenSDK, if you encounter problems, here is available here for the developer reference:https://github.com/authing/AuthingIOSDemo (opens new window) .

¶ Running login request

After successful access SDK, you should be able to successfully open WeChat to get user authorization and get an authorization code:

Below is the initiating WeChat login request code example (Swift):

func loginByWechat() {
    let req = SendAuthReq()
    req.scope = "snsapi_userinfo" //Get user information
    req.state = "123" //The random value can be used here,
    WXApi.send(req)
}

You can get the authorization code Code on AppDelegate or SceneDelegate, as shown below:

¶ Receive WeChat callback data acquisition code

Here is an example code (Swift language):

func onResp(_ resp: BaseResp) {

    debugPrint(resp)

    // WeChat login request information
    if resp.isKind(of: SendAuthResp.self) {
        if resp.errCode == 0 && resp.type == 0{
            let response = resp as! SendAuthResp

            // WeChat authorication_code
            let code = response.code
            debugPrint("code: " ,code)
        }
    }
}

¶ Exchange user information

The user agreed to get the code, you can call Swift SDK loginByWeChatCode to get the user information:

func loginByWeChatCode() {
    let code = "code"
    // Normal
    self.client?.loginByWeChatCode(code: code, completion: { status in
        print(status)
    })
}

¶ Next

After obtaining the user information, you can get the user's identity credential (the token field ), which you can carry in subsequent requests sent by the client to the backend server token, for axios example :

const axios = require("axios");
axios
  .get({
    url: "https://yourdomain.com/api/v1/your/resources",
    headers: {
      Authorization: "Bearer ID_TOKEN"
    }
  })
  .then(res => {
    // custom codes
  });

The legitimacy of this needs to be checked in the back-end interface to verify the user's identity. For details of the verification method, see Verifying User Identity Credentials (token) . After identifying the user's identity, you may also need to perform permission management on the user to determine whether the user has permission to operate this API.

  • Step 1: Create a WeChat mobile app on the WeChat open platform
  • Step 2: Configure WeChat mobile app on Authing console
  • Step 3: Start development access
  • Next

User identity management

Integrated third-party login
Mobile phone number flash check (opens new window)
Universal login form component
Custom authentication process

Enterprise internal management

Single Sign On
Multi-factor Authentication
Authority Management

Developers

Development Document
Framework Integration
Blog (opens new window)
GitHub (opens new window)
Community User Center (opens new window)

Company

400 888 2106
sales@authing.cn
16 / F, Block B, NORTH STAR CENTURY CENTER, Beijing(Total)
room 406, 4th floor, zone B, building 1, No. 200, Tianfu Fifth Street, Chengdu(branch)

Beijing ICP No.19051205-1

© Beijing Steamory Technology Co.