Authing DocsDocuments
Concept
workflow
Guides
Development Integration
Application integration
Concept
workflow
Guides
Development Integration
Application integration
Old Version
Development Integration
  • Single Sign-On (SSO)
  • Login component

  • JavaScript/Node.js

  • Java / Kotlin

  • Python

  • C#

  • PHP

  • Go

  • Ruby
  • Android

  • iOS

    • Quick start
    • Auth Flow
    • APIs

      • Authentication
      • OIDC
      • MFA
      • User management
      • Scan to login
    • Third-party identity source

    • Typical scene

    • On-premise
    • WebAuthn
    • Error Code List
  • Flutter

  • React Native
  • WeChat Mini Program
  • WeChat webpage authorization
  • Framework Integration
  • Error code
  1. Development Integration
  2. /
  3. iOS
  4. /
  5. APIs
  6. /
  7. User management

¶ User management API

Update Time: 2026-03-25 09:13:34
Edit

¶ Get custom data

Get all custom data for the user. You need to be in the user pool Define user-defined data meta information (opens new window). User-defined data is added to the passed userInfo object. A login is required to invoke this interface.

func getCustomUserData(userInfo: UserInfo, completion: @escaping(Int, String?, UserInfo?) -> Void)

Parameter

  • userInfo

Example

AuthClient().getCustomUserData(userInfo: Authing.getCurrentUser()) { code, message, userInfo in
    if (code == 200) {
        userInfo.customData // [NSMutableDictionary]?
    }
}

Error Code

  • 2020 Not logged in

¶ Set custom data

Set the user's custom field. You need to be in the userpoolDefine user-defined data meta information (opens new window), and the type of incoming value must match the defined type. A login is required to invoke this interface.

func setCustomUserData(customData: NSDictionary, completion: @escaping(Int, String?, NSDictionary?) -> Void)

Parameter

  • customData JSONObject in the form of key-value

Example

let object = ["your_custom_data_key": "your_custom_data_value"]
AuthClient().setCustomUserData(customData: object) { code, message, data in
    if (code == 200) {

    }
}

Error Code

  • 2020 Not logged in

¶ Update user profile picture

Update the user profile picture by selecting an image from the system. A login is required to invoke this interface.

func uploadAvatar(image: UIImage, completion: @escaping(Int, String?, UserInfo?) -> Void)

Parameter

  • image Image input stream. You are advised to use the default image picker

Example

Start the system default image selector

let picker = UIImagePickerController()
picker.delegate = self
picker.allowsEditing = true
picker.sourceType = UIImagePickerController.SourceType.photoLibrary
self.viewController?.present(picker, animated: true, completion: nil)

In the startup code, picker.delegate needs to implement UINavigationControllerDelegate, UIImagePickerControllerDelegate protocol

Get the picture through the following callback, and call the update avatar interface

public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    if let image = info[.editedImage] as? UIImage {
        AuthClient().uploadAvatar(image: image) { code, message, userInfo in
            if (code == 200) {
                print("upload success")
            } else {
                print("upload failed")
            }
        }
    } else {
        print("pick image error")
    }
    
    picker.dismiss(animated: true, completion:nil)
}

Error Code

  • 2020 Not logged in

¶ Modify user profile

Modify user information, this interface cannot be used to modify the mobile phone number, email, password.

func updateProfile(_ object: NSDictionary, completion: @escaping(Int, String?, UserInfo?) -> Void)

Parameter

  • object Modified user profile

Fields of data can be updated through this interface:

  • username
  • nickname
  • company
  • photo
  • browser
  • device
  • name
  • givenName
  • familyName
  • middleName
  • profile
  • preferredUsername
  • website
  • gender
  • birthdate
  • zoneinfo
  • locale
  • address
  • streetAddress
  • locality
  • region
  • postalCode
  • city
  • province
  • country

Example

let object = ["username": "elonmusk", "nickname": "Ironman"]
AuthClient().updateProfile(object: object) { code, message, userInfo in
    if (code == 200) {

    }
}

Error Code

  • 2020 Not logged in

¶ Get user account security level

Get user account security level.

func getSecurityLevel(completion: @escaping(Int, String?, NSDictionary?) -> Void)

Example

AuthClient().getSecurityLevel { code, message, data in
    if (code == 200) {

    }
}

Callback data data structure

{
    "score": 60,
    "email": false,
    "phone": false,
    "password": true,
    "passwordSecurityLevel": 1,
    "mfa": false
}

Error Code

  • 2020 Not logged in

¶ Refreshes the Token of the current user

func updateIdToken(completion: @escaping(Int, String?, UserInfo?) -> Void)

Example

AuthClient().updateIdToken { code, message, userInfo in
    if (code == 200) {

    }
}

Error Code

  • 2020 Not logged in

¶ Get applications that current users can access

Get the application that the current user can access. Note that the returned result data structure is List<Application>.

func listApplications(page: Int = 1, limit: Int = 10, completion: @escaping(Int, String?, NSArray?) -> Void)

Parameter

  • page Page serial number, default is 1.
  • limit The number of times returned per page, the default is 10.

Example

AuthClient().listApplications { code, message, applications in
    if (code == 200) {

    }
}

Callback data data structure

{
    "code": 200,
    "message": "Success",
    "data": {
        "list": [
            {
                "id": "61ae0c9807451d6f30226bd4",
                "name": "lance-test",
                "logo": "https://files.authing.co/authing-console/default-app-logo.png",
                "domain": "lance-test",
                "description": null,
                "createdAt": "2021-12-06T13:14:01.123Z",
                "updatedAt": "2022-01-20T10:51:02.806Z",
                "protocol": "oidc",
                "isIntegrate": false,
                "appType": "INDIVIDUAL",
                "template": null
            }
        ],
        "totalCount": 1
    }
}

Error Code

  • 2020 Not logged in

¶ Get list of data data in users

Obtain the organization of the user. Because the user can be in multiple independent organization trees, this interface returns a two-digit array. Note that the returned result data structure is List<Organization[]>.

func listOrgs(completion: @escaping(Int, String?, NSArray?) -> Void)

Example

AuthClient().listOrgs { code, message, organizations in
    if (code == 200) {

    }
}

Callback data data structure

{
    "code": 200,
    "message": "Success",
    "data": [
        [
            {
                "type": "org",
                "id": "6108e6fd64c0de1975728fe9",
                "createdAt": "2021-08-03T06:49:33.907Z",
                "updatedAt": "2021-08-03T06:49:33.920Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "rootNodeId": "6108e6fd552ad0a95a2ac771",
                "logo": null,
                "tenantId": null
            },
            {
                "type": "node",
                "id": "6108e6fd552ad0a95a2ac771",
                "createdAt": "2021-08-03T06:49:33.911Z",
                "updatedAt": "2021-08-03T06:49:33.911Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "6108e6fd64c0de1975728fe9",
                "name": "HR",
                "nameI18n": null,
                "description": null,
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            },
            {
                "type": "node",
                "id": "6108e710d2120ac0eb9af7d7",
                "createdAt": "2021-08-03T06:49:52.670Z",
                "updatedAt": "2021-08-03T06:49:52.670Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "6108e6fd64c0de1975728fe9",
                "name": "DevHR",
                "nameI18n": null,
                "description": null,
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            },
            {
                "type": "node",
                "id": "6108e7763c30fecb43f9b6a4",
                "createdAt": "2021-08-03T06:51:34.505Z",
                "updatedAt": "2021-08-03T06:51:34.505Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "6108e6fd64c0de1975728fe9",
                "name": "swiftDevHR",
                "nameI18n": null,
                "description": null,
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            }
        ],
        [
            {
                "type": "org",
                "id": "61e9408778066eaab14965de",
                "createdAt": "2022-01-20T10:59:19.035Z",
                "updatedAt": "2022-01-20T10:59:19.051Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "rootNodeId": "61e94087cf40643c9637e03c",
                "logo": null,
                "tenantId": null
            },
            {
                "type": "node",
                "id": "61e94087cf40643c9637e03c",
                "createdAt": "2022-01-20T10:59:19.042Z",
                "updatedAt": "2022-01-20T10:59:19.042Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "61e9408778066eaab14965de",
                "name": "RD",
                "nameI18n": null,
                "description": null,
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            },
            {
                "type": "node",
                "id": "61e94092ac13f7afd26d05b7",
                "createdAt": "2022-01-20T10:59:30.405Z",
                "updatedAt": "2022-01-20T10:59:30.405Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "61e9408778066eaab14965de",
                "name": "Mobile",
                "nameI18n": null,
                "description": null,
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            }
        ],
        [
            {
                "type": "org",
                "id": "6108e6fd64c0de1975728fe9",
                "createdAt": "2021-08-03T06:49:33.907Z",
                "updatedAt": "2021-08-03T06:49:33.920Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "rootNodeId": "6108e6fd552ad0a95a2ac771",
                "logo": null,
                "tenantId": null
            },
            {
                "type": "node",
                "id": "6108e6fd552ad0a95a2ac771",
                "createdAt": "2021-08-03T06:49:33.911Z",
                "updatedAt": "2021-08-03T06:49:33.911Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "6108e6fd64c0de1975728fe9",
                "name": "HR",
                "nameI18n": null,
                "description": null,
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            },
            {
                "type": "node",
                "id": "6108e710d2120ac0eb9af7d7",
                "createdAt": "2021-08-03T06:49:52.670Z",
                "updatedAt": "2021-08-03T06:49:52.670Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "6108e6fd64c0de1975728fe9",
                "name": "DevHR",
                "nameI18n": null,
                "description": null,
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            },
            {
                "type": "node",
                "id": "62039e6b017b8cf3b5bb6ec4",
                "createdAt": "2022-02-09T10:58:51.422Z",
                "updatedAt": "2022-02-09T10:59:16.718Z",
                "userPoolId": "60caaf41da89f1954875cee1",
                "orgId": "6108e6fd64c0de1975728fe9",
                "name": "SwiftDevHR",
                "nameI18n": null,
                "description": "",
                "descriptionI18n": null,
                "order": null,
                "code": null,
                "leaderUserId": null
            }
        ]
    ]
}

Error Code

  • 2020 Not logged in

¶ Get the list of roles owned by users

Get the list of roles owned by users. Note that the returned result data structure is NSArray<Role>.

func listRoles(namespace: String? = nil, completion: @escaping(Int, String?, NSArray?) -> Void)

Parameter

  • namespace Permission group ID, used to filter role data. If empty, all roles of the user are returned

Example

AuthClient().listRoles { code, message, roles in
    if (code == 200) {

    }
}

Callback data data structure

{
    "code": 200,
    "message": "Success",
    "data": [
        {
            "id": "61ada935ce061fe3476f0f09",
            "createdAt": "2021-12-06T06:09:57.523Z",
            "updatedAt": "2021-12-06T06:09:57.523Z",
            "userPoolId": "60caaf41da89f1954875cee1",
            "code": "admin",
            "description": null,
            "parentCode": null,
            "isSystem": false,
            "namespaceId": 36141,
            "namespace": "60caaf414f9323f25f64b2f4"
        }
    ]
}

Error Code

  • 2020 Not logged in

¶ Get all the list of users authorized to be authorized

Gets all resources authorized by users, and users are authorized to include resources that are inherited from roles, packets, and organizational institutions.

func listAuthorizedResources(namespace: String = "default", resourceType: String? = nil, completion: @escaping(Int, String?, NSArray?) -> Void)

Parameter

  • namespace Permission group ID.
  • resourceType Resource type. Can be the following types of DATA, API, MENU, UI, BUTTON. If null, all resource type data is returned.

Example

AuthClient().listAuthorizedResources { code, message, resources in
    if (code == 200) {

    }
}

Callback data data structure

{
    "totalCount": 1,
    "list": [
        {
            "code": "ci:*",
            "type": "DATA",
            "actions": [
                "*"
            ],
            "apiIdentifier": null
        }
    ]
}

Error Code

  • 2020 Not logged in

¶ Delete the account

Users can delete their current login accounts.

This operation cannot be reversed. Therefore, you must prompt the user.

func deleteAccount(completion: @escaping(Int, String?) -> Void)

Example

let cancel = NSLocalizedString("authing_cancel", bundle: Bundle(for: Self.self), comment: "")
let tip = NSLocalizedString("authing_delete_account_tip", bundle: Bundle(for: Self.self), comment: "")
let alert = UIAlertController(title: nil, message: tip, preferredStyle: UIAlertController.Style.alert)

alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action: UIAlertAction!) in
    AuthClient().deleteAccount { code, message in
        if (code == 200) {
            
        }
    }
}))

alert.addAction(UIAlertAction(title: cancel, style: .cancel, handler: { (action: UIAlertAction!) in
    alert.dismiss(animated: true, completion: nil)
}))

viewController?.present(alert, animated: true, completion: nil)

Prev: MFA Next: Scan to login
  • Get custom data
  • Set custom data
  • Update user profile picture
  • Modify user profile
  • Get user account security level
  • Refreshes the Token of the current user
  • Get applications that current users can access
  • Get list of data data in users
  • Get the list of roles owned by users
  • Get all the list of users authorized to be authorized
  • Delete the account

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.