Signing in with an email and a password belongs to an account surface, not to an SDK: a program holds a key, not a password. What is here is what a program needs — end this session, end another one, change the profile it belongs to.
The methods
| Method | Does | Returns |
|---|---|---|
| logout() | Ends the session this client is using. | { ok: true } |
| revokeSession(id) | Ends another session of the same account, by id. | { ok: true } · 404 |
| updateProfile(updates) | Changes writable profile fields. | { ok, user } |
Key, session, request
Three things sit between your code and an answer, and each is revoked differently. Knowing which one you are holding is most of what this resource is about.
| What it is | Ends when | |
|---|---|---|
| The key | What the account issued to your program. | You revoke it. |
| The session | What the key was exchanged for. | logout(), revokeSession(), or it expires. |
| The token | The short-lived proof on each request. | It expires, and is renewed from the session. |
Ending a session does not stop the key: the next call exchanges it again and you are back, under a new session. To cut access, revoke the key.
What is not here, and where it is
| What you want | Where |
|---|---|
| Who this key belongs to | api.getUser() |
| Which session this is | api.session() |
| Stop a key from working at all | api.keys.revoke(id) |
| The balance and the plan | api.getUser() |
| Sign in with an email and password | Not an SDK operation. Your account surface does it. |
Choosing between the three
// This process should stop being this session
await api.auth.logout();
// That machine over there should be signed out
await api.auth.revokeSession(itsSessionId);
// That machine should not be able to come back at all
await api.keys.revoke(itsKeyId);
// All of the above, for a machine you no longer trust:
await api.keys.revoke(itsKeyId);
await api.auth.revokeSession(itsSessionId);# This process should stop being this session
api.auth.logout()
# That machine over there should be signed out
api.auth.revoke_session(its_session_id)
# That machine should not be able to come back at all
api.keys.revoke(its_key_id)
# All of the above, for a machine you no longer trust:
api.keys.revoke(its_key_id)
api.auth.revoke_session(its_session_id)The order is deliberate. Revoking the key first closes the door; revoking the session then removes whoever was already inside. Doing it the other way round leaves a window in which the key is used to exchange a fresh session.