返回值
{ ok: true }{"ok": True}没有什么可以传递的:会话是从您已经发送的牌子上识别的。 它的刷新牌子停止在同一时刻更新—— 这不是一个以后过期的牌子, 而是结束的会话。
下次电话发生什么
缓存的标记不再被接受, 刷新失败, 键被交换。 您的代码在新的会话下继续工作。 很少有人会这样叫它 logout() 仔细想想,你们想看哪一个。
await api.auth.logout();
await api.getUser(); // works — a different session nowapi.auth.logout()
api.get_user() # works — a different session now| 想要什么 | 调用 |
|---|---|
| 停止为本届会议的进程 | api.auth.logout() |
| 此密钥可以停止工作 | api.keys.revoke(id) |
| 另一要签名的设备 | api.auth.revokeSession(id) |
两次调用它
第二次是会议之下发出的呼吁,第一次是呼吁引起的,因此,它回答了 { ok: true } 你们应当使那段经典成为最后的,那不是错误,也不是断绝的。无论会议是何时举行的,每件事都以结束。
当那经是正经的时候,
- 一份短命的工作已经完成了,你宁愿不留下一个会议 活着在它后面。
- 显示访客外出 其会话是访客的 而不是您的服务器的
- 一台机器被退役——同时取消它所拥有的钥匙。
当它不是:作为长期服务器的清理。在那里,会话让你的电话变得便宜—— 结束每次关闭就意味着在下一靴子上再次交换钥匙。
结束工作会 干净干净地结束工作
try {
await doTheWork(api);
} finally {
// Best effort: the work is done either way, and a failed logout
// must not become the error the caller sees.
await api.auth.logout().catch(() => {});
}from iagenify import IaGenifyError
try:
do_the_work(api)
finally:
# Best effort: the work is done either way, and a failed logout
# must not become the error the caller sees.
try:
api.auth.logout()
except IaGenifyError:
pass在浏览器中, 清除隐藏的东西
会话被保存在页面自己的仓库中。 结束服务器端的服务器端留下一个死条目, 下次调用时会尝试换换。 替换客户端, 或者清除商店 。
await api.auth.logout();
// The page keeps its own copy. Clear it, or the next call tries a dead token first.
await myStore.clear();api.auth.logout()
# A custom store keeps its own copy. Clear it, or the next call tries a dead token first.
my_store.clear()