Tham chiếu API

Phiên

Tạo mã API có tên và trả về clientId cùng token 32 byte được mã hóa Base64. Liệt kê phiên đăng nhập và phiên mã API. Với LOGIN, token và urlToken rỗng; thông tin xác thực API_TOKEN chỉ được đọc qua yêu cầu của chủ sở hữu cục bộ.

Định nghĩa kiểu

graphql
type Mutation {
  createApiToken(name: String!): CreatedApiToken!
  renameSession(clientId: ID!, name: String!): Boolean!
  revokeSession(clientId: ID!): Boolean!
}

type Query {
  sessions: [Session!]!
}

type CreatedApiToken {
	clientId: ID!
	token: String!
}

scalar Instant

type Session {
	clientId: ID!
	clientName: String!
	type: SessionType!
	clientIp: String!
	osName: String!
	osVersion: String!
	appName: String!
	appVersion: String!
	lastSeenAt: Instant
	lastActive: Instant!
	createdAt: Instant!
	updatedAt: Instant!
}

enum SessionType {
	LOGIN
	API_TOKEN
}

Thao tác

mutation

createApiToken

Tạo mã API có tên và trả về clientId cùng token 32 byte được mã hóa Base64.

graphql
mutation createApiToken($name: String!) {
  createApiToken(name: $name) { clientId token }
}
mutation

renameSession

Đổi tên phiên máy khách được cấp quyền đã chỉ định.

graphql
mutation renameSession($clientId: ID!, $name: String!) {
  renameSession(clientId: $clientId, name: $name)
}
mutation

revokeSession

Thu hồi phiên máy khách đã chỉ định và quyền truy cập của nó.

graphql
mutation revokeSession($clientId: ID!) {
  revokeSession(clientId: $clientId)
}
query

sessions

Liệt kê phiên đăng nhập và phiên mã API. Với LOGIN, token và urlToken rỗng; thông tin xác thực API_TOKEN chỉ được đọc qua yêu cầu của chủ sở hữu cục bộ.

graphql
query sessions {
  sessions { clientId clientName type clientIp osName osVersion appName appVersion }
}