# Overview

Canonical URL: https://developers.iagenify.com/sdk/ref/auth/
Language: en

The current session, and the profile behind it. Three methods — there is no sign-in here, because the SDK authenticates with a key.

Status: 3 methods · session-scoped · free

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 {#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 {#chain}

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. |

> **A session and a key are two different things**
>
> 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 {#not}

| 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 {#choosing}

```javascript
// 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);
```

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.

- [Sessions](/sdk/concepts/sessions): What a session is, and how it is renewed.
- [api.keys](/sdk/ref/keys): The keys a session is exchanged from.
- [session()](/sdk/ref/iagenify/session): Reading which session this client is using.

```python
# 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)
```
