PlainApp
API 參考

工作階段

建立具名 API 權杖,傳回 clientId 和 Base64 編碼的 32 位元組 token。 列出登入和 API 權杖工作階段。LOGIN 的 token 和 urlToken 為空;API_TOKEN 憑證僅限本機擁有者請求讀取。

型別定義

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
}

操作

mutation

createApiToken

建立具名 API 權杖,傳回 clientId 和 Base64 編碼的 32 位元組 token。

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

renameSession

重新命名指定的已授權用戶端工作階段。

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

revokeSession

撤銷指定用戶端工作階段及其存取權限。

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

sessions

列出登入和 API 權杖工作階段。LOGIN 的 token 和 urlToken 為空;API_TOKEN 憑證僅限本機擁有者請求讀取。

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