获取当前用户信息
GET/auth/v1/user/me
接口说明
获取当前登录用户的基础信息,包括用户资料、绑定身份源、角色权限等
入参要求:
Authorization: 当前登录用户的access_token(必填,请求头中传入,格式为Bearer xxx)client_id: 应用对应的客户端id(可选,默认为环境id)x-device-id: 设备id(可选,当前登录设备的id)
前置条件:
- 需要有效的access_token
- 用户必须已登录
出参:
- 返回完整的用户信息对象(v1Profile)
- 包含用户基本信息、绑定身份源、角色权限、状态等
获取用户信息请求示例
GET /auth/v1/user/me
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FwaS5leGFtcGxlLmNvbSIsInN1YiI6Ijk4NzY1NDMyMTAxMjM0NTY3ODkiLCJhdWQiOiJkZW1vLWFwcC0yZjhhOWMzZTFiNGQiLCJleHAiOjE3MzQ2NzU4ODksImlhdCI6MTczNDY2ODY4OSwic2NvcGUiOiJ1c2VyIn0.dGhpc19pc19hX2Zha2Vfc2lnbmF0dXJlX2Zvcl9leGFtcGxlX3B1cnBvc2VzX29ubHlfZG9fbm90X3VzZV9pbl9wcm9kdWN0aW9uX2Vudmlyb25tZW50X3RoaXNfaXNfbm90X3JlYWxfdG9rZW5fZGF0YQ
x-device-id: device_123456
获取用户信息响应示例
{
"sub": "9876543210123456789",
"name": "张三",
"picture": "https://example/avatar.jpg",
"username": "zhangsan",
"email": "zhangsan@example",
"phone_number": "+86 13000000000",
"providers": [
{
"id": "email",
"provider_user_id": "zhangsan@example",
"name": "邮箱登录",
"picture": "",
"url": "",
"meta": {}
}
],
"status": "ACTIVE",
"gender": "MALE",
"groups": [
{
"id": "user"
}
],
"meta": {
"department": "技术部",
"position": "开发工程师"
},
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-15T10:30:00Z",
"password_updated_at": "2023-01-01T00:00:00Z",
"user_id": "9876543210123456789",
"has_password": true,
"internal_user_type": "generalUser",
"type": "external",
"user_source": 1,
"user_desc": "普通用户",
"last_login": "2023-01-15T10:30:00Z"
}
使用场景:
- 用户登录后获取个人信息
- 展示用户资料页面
- 检查用户权限和角色
- 获取用户绑定的登录方式
关键特性:
- 返回完整的用户信息,包括敏感信息(邮箱、手机号等)
- 包含用户绑定的所有身份源信息
- 显示用户状态和角色权限
- 提供用户扩展信息(meta字段)
Request
Query Parameters
client_id string
应用对应的客户端id,可从云开发平台-->身份认证-->开发设置获取。默认为环境id,可以不传
Header Parameters
x-device-id string
设备id,当前登录设备的id。客户端应随机生成,并缓存到客户端。此参数与登录账号数有关
Authorization stringrequired
当前登录用户的access_token, 值的格式为Bearer xxx
Example: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FwaS5leGFtcGxlLmNvbSIsInN1YiI6Ijk4NzY1NDMyMTAxMjM0NTY3ODkiLCJhdWQiOiJkZW1vLWFwcC0yZjhhOWMzZTFiNGQiLCJleHAiOjE3MzQ2NzU4ODksImlhdCI6MTczNDY2ODY4OSwic2NvcGUiOiJ1c2VyIn0.dGhpc19pc19hX2Zha2Vfc2lnbmF0dXJlX2Zvcl9leGFtcGxlX3B1cnBvc2VzX29ubHlfZG9fbm90X3VzZV9pbl9wcm9kdWN0aW9uX2Vudmlyb25tZW50X3RoaXNfaXNfbm90X3JlYWxfdG9rZW5fZGF0YQ
- application/json
Body
- any
Responses
- 200
- 500
A successful response.
Response Headers
- application/json
- Schema
- Example (from schema)
Schema
- Array [
- ]
- Array [
- ]
sub string
用户sub
name string
用户昵称
picture string
头像
username string
用户名
email string
邮箱
phone_number string
手机号
providers object[]
用户绑定的登录方式
id string
身份源ID
provider_user_id string
身份源用户ID
name string
身份源名称
picture string
身份源头像
url string
身份源URL
meta object
身份源扩展信息
property name* string
status ProfileProfileStatus (string)
Possible values: [DEFAULT, ACTIVE, PENDING, BLOCKED]
用户状态
gender string
性别
groups object[]
用户组, 用户绑定的角色标识列表
id string
角色标识
meta object
用户扩展信息
property name* string
created_at date-time
创建时间
updated_at date-time
更新时间
password_updated_at date-time
密码更新时间
user_id string
微搭用户ID
has_password boolean
是否有密码
internal_user_type string
内部用户类型, 内置超管-administrator、普通用户-generalUser
type string
用户类型, 内部用户-internal、外部用户-external
user_source int32
用户来源, 1-自建, 2-企业微信, 3-外部注册
user_desc string
用户描述
open_id string
微信或企微的openID
corp_id string
企业ID
parent_user_id string
直属上级ID
main_dep string
主岗部门ID
sort int32
排序值, sort越小, 排序越靠前
last_login date-time
最近登录时间
{
"sub": "string",
"name": "string",
"picture": "string",
"username": "string",
"email": "string",
"phone_number": "string",
"providers": [
{
"id": "string",
"provider_user_id": "string",
"name": "string",
"picture": "string",
"url": "string",
"meta": {}
}
],
"status": "DEFAULT",
"gender": "string",
"groups": [
{
"id": "string"
}
],
"meta": {},
"created_at": "2024-07-29T15:51:28.071Z",
"updated_at": "2024-07-29T15:51:28.071Z",
"password_updated_at": "2024-07-29T15:51:28.071Z",
"user_id": "string",
"has_password": true,
"internal_user_type": "string",
"type": "string",
"user_source": 0,
"user_desc": "string",
"open_id": "string",
"corp_id": "string",
"parent_user_id": "string",
"main_dep": "string",
"sort": 0,
"last_login": "2024-07-29T15:51:28.071Z"
}
An unexpected error response.
Response Headers
- application/json
- Schema
- Example (from schema)
Schema
error 错误信息 (string)
error_code int32
error_description 错误描述 (string)
{
"error": "string",
"error_code": 0,
"error_description": "string"
}
Loading...