LoginWithPassword creates a session token authenticating with an email and password. Call `SetSessionToken()` to apply the newly acquired token to the client.
(ctx context.Context, req LoginWithPasswordRequest)
| 897 | // LoginWithPassword creates a session token authenticating with an email and password. |
| 898 | // Call `SetSessionToken()` to apply the newly acquired token to the client. |
| 899 | func (c *Client) LoginWithPassword(ctx context.Context, req LoginWithPasswordRequest) (LoginWithPasswordResponse, error) { |
| 900 | res, err := c.Request(ctx, http.MethodPost, "/api/v2/users/login", req) |
| 901 | if err != nil { |
| 902 | return LoginWithPasswordResponse{}, err |
| 903 | } |
| 904 | defer res.Body.Close() |
| 905 | if res.StatusCode != http.StatusCreated { |
| 906 | return LoginWithPasswordResponse{}, ReadBodyAsError(res) |
| 907 | } |
| 908 | var resp LoginWithPasswordResponse |
| 909 | err = json.NewDecoder(res.Body).Decode(&resp) |
| 910 | if err != nil { |
| 911 | return LoginWithPasswordResponse{}, err |
| 912 | } |
| 913 | return resp, nil |
| 914 | } |
| 915 | |
| 916 | func (c *Client) RequestOneTimePasscode(ctx context.Context, req RequestOneTimePasscodeRequest) error { |
| 917 | res, err := c.Request(ctx, http.MethodPost, "/api/v2/users/otp/request", req) |