Logout calls the /logout API Call `ClearSessionToken()` to clear the session token of the client.
(ctx context.Context)
| 971 | // Logout calls the /logout API |
| 972 | // Call `ClearSessionToken()` to clear the session token of the client. |
| 973 | func (c *Client) Logout(ctx context.Context) error { |
| 974 | // Since `LoginWithPassword` doesn't actually set a SessionToken |
| 975 | // (it requires a call to SetSessionToken), this is essentially a no-op |
| 976 | res, err := c.Request(ctx, http.MethodPost, "/api/v2/users/logout", nil) |
| 977 | if err != nil { |
| 978 | return err |
| 979 | } |
| 980 | defer res.Body.Close() |
| 981 | return nil |
| 982 | } |
| 983 | |
| 984 | // User returns a user for the ID/username provided. |
| 985 | func (c *Client) User(ctx context.Context, userIdent string) (User, error) { |