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 a small program to log in

Update Time: 2025-06-11 08:01:00
Edit

Moving App Pull A Small Program Login is a key way to establish a mobile phone number as a central user system. Authing Through SDK, the developer greatly reduces the development of complexity, one line of code can obtain the mobile phone number authorized in the applet by the mobile terminal, establish an account system based on the mobile phone number.

  • Application scenario: Mobile APP;
  • Overview: Pull up the WeChat applet in your mobile application for login.
  • 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 creates a WeChat mobile app, andWeChat open platform (opens new window) control center - Mobile Applications - Application details - Associate small program information page, To initiate an associated small program operation by an auditing mobile application. Required applet- Small login AppID is wxa0435021fd7a3af2.

¶ Step 2: Create a WeChat applet in the WeChat open platform (optional)

By default, the app pulls a mini program login. Authing default mini program is provided, if you need a stronger brand customization capability, or if you want to get the user WeChat account and your other WeChat public platform to log in through the applet, you need to apply for your own applet. If you belong to these two scenarios:

Please go to the WeChat public platform (opens new window) guide creates a WeChat applet, you need to record the App ID and App Secret of the app, will be used later.

At the same time, you need to contact us to get the source code of your login. For details, please consult Authing Contact.

¶ Step 3: Configure "App Pull up a Small Program Login" app in the Authing console (optional)

In the console's social login configuration page, find the app pull a mini program login, fill in the following configuration:

  • AppID: AppId of mini program, select the user fill the privatization applet;
  • AppSecret: mini program AppSecret,Select the user who is privatatically applying a mini program.

¶ Step 4: Start development access

¶ Pull up WeChat mini program

Developers need to call WechatOpenSDK(Please see WeChat official document (opens new window):

  • mini program userName is gh_a781a791e29e
  • path is /routers/explore
  • path query parameter is:
    • userPoolId: Your userpool ID
    • getPhone: you need to get the user's mobile phone number, 1 means need, not fill or other means
    • fromApp: 1, this parameter must be filled.
    • useSelfWxapp: 0. This parameter is required.

Take swift language as an example:

let userPoolId = "5e4cdd055df3df65dc58b97d"
let req = WXLaunchMiniProgramReq()
req.userName = "gh_a781a791e29e"
req.path = "/routes/explore?userPoolId=\(userPoolId)&getPhone=1&fromApp=1&useSelfWxapp=0"
req.miniProgramType = WXMiniProgramType.test
WXApi.send(req)

¶ Receive data returned by the applet

Small login will return a string URL Query String to the app, and the developer can convert it into a dictionary:

  • code: The business status code, 200 is successful.
  • message: Tip information.
  • ticket: The authorization is successful. Developers can use this acquisition user information
func onResp(_ resp: BaseResp) {
    print("onResp: type=\(resp.type)")
    if resp.isKind(of: WXLaunchMiniProgramResp.self ) {
        if resp.errCode == 0 && resp.type == 0{//Authorized success
            let response = resp as! WXLaunchMiniProgramResp
            let extMsg = response.extMsg!
            //  WeChat login successful notice
            debugPrint(extMsg)
            let arr = extMsg.components(separatedBy:"&")
            var data = [String:Any]()
            for row in arr {
                let pairs = row.components(separatedBy:"=")
                data[pairs[0]] = pairs[1]
            }
            let code = data["code"]
            let message = data["message"]
            let ticket = data["ticket"]
            debugPrint(code, message, ticket)
        }
    }
}

¶ Get user information

User agrees that the developer can use Ticket to exchange user information, Ticket default valid time is two minutes. By default, for security reasons, Ticket exchanges user information requires a user pool key, which means that user information cannot be exchanged directly within the app. We also provide the right to developer choices, developers can modify this option in the user pool base configuration page (see above).

POST
https://core.authing.cnoauth/app2wxapp/auth/:userPoolId

ticket exchange user information

Headers
content-type
REQUIRED
string

application/json

Path Paramter
userPoolId
REQUIRED
string

Userpool ID

Body Paramter
secret
OPTIONAL
string

Userpool key

tickett
REQUIRED
string

ticket returns to App

200: OK

_id is user ID。

{
  emailVerified: false,
  username: 'Liao Changjiang',
  nickname: 'Liao Changjiang',
  company: '',
  photo: 'https://usercontents.authing.cn/avatar-5e57540f84622ae263294a42-1582781455906',
  loginsCount: 2,
  registerMethod: 'oauth:app2wxapp',
  blocked: false,
  isDeleted: false,
  oauth: '{"nickName":"Liang Changjiang","gender":1,"language":"zh_CN","city":"Haidian","province":"Beijing","country":"China","avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/8INxh2bxDMiaU05jLqvWBszALu2u8Qw4iaxV58v4fERaDWV8yunE7icNiahJdxkOCNfGosqXcQ2SyScAcdyibv8uWWQ/132","phone":"17670416754","openid":"o1p9H4wAgb9uTqpxG5Z1g0pIr3FE","unionid":"o0pqE6Fbr5M-exSu_PeL_sjwN44U"}',
  metadata: '""',
  _id: "5e57540f84622ae263294a42",
  unionid: 'o0pqE6Fbr5M-exSu_PeL_sjwN44U',
  openid: 'o1p9H4wAgb9uTqpxG5Z1g0pIr3FE',
  lastIP: '::ffff:192.168.0.106',
  lastLogin: "2020-02-27T05:33:20.796Z",
  signedUp: "2020-02-27T05:30:55.875Z",
  token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVuaW9uaWQiOiJvMHBxRTZGYnI1TS1leFN1X1BlTF9zandONDRVIiwiaWQiOiI1ZTU3NTQwZjg0NjIyYWUyNjMyOTRhNDIiLCJjbGllbnRJZCI6IjVlNGNkZDA1NWRmM2RmNjVkYzU4Yjk3ZCJ9LCJpYXQiOjE1ODI3ODE2MDAsImV4cCI6MTU4NDA3NzYwMH0.pd7HJu5Ft8uytxIy4VgHdQiaAKuo96P_LcABFwM7OPI',
  tokenExpiredAt: "2020-03-13T05:33:20.000Z",
  phone: '188xxxx8888'
}

swift Code example:

import Alamofire

struct Body: Encodable {
    let ticket: String
}
let body = Body(ticket: ticket)
let url = "https://core.authing.cn/oauth/app2wxapp/auth/5e4cdd055df3df65dc58b97d?ticket=\(ticket)"
AF.request(
    url,
    method: .post,
    parameters: body,
    encoder: JSONParameterEncoder.default
).responseJSON { response in
    debugPrint("Response: \(response)")
}

¶ 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: Create a WeChat applet in the WeChat open platform (optional)
  • Step 3: Configure "App Pull up a Small Program Login" app in the Authing console (optional)
  • Step 4: 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.