Files
kleiax 904d14b64c
CI / test (push) Canceled after 0s
Initial commit
2026-09-12 22:22:17 +02:00

34 lines
1.2 KiB
Go

package client
import (
"context"
"net/http"
)
// CreateAuthenticationToken exchanges credentials for a bearer token.
func (c *Client) CreateAuthenticationToken(ctx context.Context, credentials Credentials) (AuthenticationToken, *Response, error) {
var envelope struct {
Token AuthenticationToken `json:"authentication_token"`
}
response, err := c.do(ctx, http.MethodPost, "v1/tokens/authentication", credentials, &envelope)
return envelope.Token, response, err
}
// CreateActivationToken requests a new account activation email.
func (c *Client) CreateActivationToken(ctx context.Context, email string) (string, *Response, error) {
var envelope struct {
Message string `json:"message"`
}
response, err := c.do(ctx, http.MethodPost, "v1/tokens/activation", EmailInput{Email: email}, &envelope)
return envelope.Message, response, err
}
// CreatePasswordResetToken requests password reset instructions for email.
func (c *Client) CreatePasswordResetToken(ctx context.Context, email string) (string, *Response, error) {
var envelope struct {
Message string `json:"message"`
}
response, err := c.do(ctx, http.MethodPost, "v1/tokens/password-reset", EmailInput{Email: email}, &envelope)
return envelope.Message, response, err
}