GenAuth DocsDocuments
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Old version
  • Single Page Web Application

  • Mobile and Client Applications

  • Standard Web Application

    • Java

      • Installation and Usage
      • User Authentication Module
      • Management Module

        • User Management

          • Get User Information
          • Batch Get User Information
          • Get User List
          • Get User External Identity Sources
          • Get User Role List
          • Get User Real-name Authentication Information
          • Delete User Real-name Authentication Information
          • Get User Department List
          • Set User Departments
          • Get Group List
          • Delete Users
          • Get User MFA Binding Information
          • Get Archived User List
          • Force User Logout
          • Check if User Exists
          • Create User
          • Batch Create Users
          • Update User Profile
          • Get User Accessible Applications
          • Get User Authorized Applications
          • Check if User Has Role
          • Get User Login History
          • Get Applications User Has Logged Into
          • Get Identity Sources User Has Logged Into
          • Get All Resources Authorized to User
        • Group Management

        • Role Management

        • Organization Management

        • Access Control Management

        • External Identity Source Management

        • Custom Field Management

    • Node.js

    • Python

  • Framework Integration

  • Others

  1. Development Integration
  2. /
  3. Standard Web Application
  4. /
  5. Java
  6. /
  7. Management Module

  8. /
  9. User Management

  10. /
  11. Get User Login History

¶ 获取用户的登录历史记录

Update time: 2025-07-23 07:34:21
Edit

通过用户 ID,获取用户登录历史记录,支持分页,可以选择指定用户 ID 类型、应用 ID、开始与结束时间戳等。

¶ 请求参数

名称类型必填默认值描述示例值
userIdstring是-用户 ID。6229ffaxxxxxxxxcade3e3d9
userIdTypestring否user_id用户 ID 类型,可以指定为用户 ID、手机号、邮箱、用户名和 externalId。。 枚举值:user_id,external_id,phone,email,usernameuser_id
appIdstring否-应用 ID。
clientIpstring否-客户端 IP。127.0.0.1
startnumber否-开始时间戳(毫秒)。1647360000000
endnumber否-结束时间戳(毫秒)。1648051199000
pagenumber否1当前页数,从 1 开始。1
limitnumber否10每页数目,最大不能超过 50,默认为 10。10

¶ 示例代码

import cn.authing.sdk.java.dto.*;
import cn.authing.sdk.java.client.ManagementClient;
import cn.authing.sdk.java.model.ManagementClientOptions;

class ManagementClientTest {
    private static String ACCESS_KEY_ID = "GEN_AUTH_USERPOOL_ID";
    private static String ACCESS_KEY_SECRET = "GEN_AUTH_USERPOOL_SECRET";

    public static void main(String[] args) {
        ManagementClientOptions clientOptions = new ManagementClientOptions(ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        ManagementClient managementClient = new ManagementClient(clientOptions);



        request.setUserId("6229ffaxxxxxxxxcade3e3d9");
        request.setUserIdType("user_id");
        request.setAppId("undefined");
        request.setClientIp("127.0.0.1");
        request.setStart(1647360000000);
        request.setEnd(1648051199000);
        request.setPage(1);
        request.setLimit(10);
        UserLoginHistoryPaginatedRespDto response = managementClient.getUserLoginHistory(request);
        System.out.println(response);
    }
}

¶ 请求响应

类型: UserLoginHistoryPaginatedRespDto

名称类型描述
statusCodenumber业务状态码,可以通过此状态码判断操作是否成功,200 表示成功。
messagestring描述信息
apiCodenumber细分错误码,可通过此错误码得到具体的错误类型。
dataUserLoginHistoryPagingDto响应数据

示例结果:

{
  "statusCode": 200,
  "message": "操作成功",
  "apiCode": 20001,
  "data": {
    "list": {
      "appId": "app1",
      "appName": "App Name",
      "appLogo": "https://example.com/logo.png",
      "appLoginUrl": "https://example.com/login",
      "clientIp": "127.0.0.1",
      "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
    }
  }
}

¶ 数据结构

¶ UserLoginHistoryPagingDto

名称类型必填描述
totalCountnumber是记录总数。
listarray是响应数据。嵌套类型:UserLoginHistoryDto。

¶ UserLoginHistoryDto

名称类型必填描述
appIdstring是App ID。 示例值: app1
appNamestring是App 名称。 示例值: App Name
appLogostring是App Logo。 示例值: https://example.com/logo.png
appLoginUrlstring是App 登录地址。 示例值: https://example.com/login
clientIpstring是客户端 IP。 示例值: 127.0.0.1
userAgentstring否登录时使用的 user agent。 示例值: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
timestring是登录时间。
Previous article: Check if User Has Role Next article: Get Applications User Has Logged Into
  • 请求参数
  • 示例代码
  • 请求响应
  • 数据结构

User identity management

Integrated third-party login
Customized authentication process

Enterprise internal management

Single sign-on
Multi-factor authentication
Permission management

Developer

Development Documentation
GitHub (opens new window)

Company

official@genauth.ai
16th Floor, Building B, Beichen Century Center, Chaoyang District, Beijing (Total)
Room 406, 4th Floor, Block B, No. 200, Tianfu Fifth Street, High-tech Zone, Chengdu (Branch)

© Beijing Steamory Technology Co., Ltd.