import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
const token = await sdk.auth.register("user", "emailpass", {
email: "user@gmail.com",
password: "supersecret"
})
// all subsequent requests will use the token in the header
const { user } = await sdk.admin.invite.accept(
{
email: "user@gmail.com",
first_name: "John",
last_name: "Smith",
invite_token: "12345..."
},
){
"token": "<string>"
}This API route retrieves a registration JWT token of a user that hasn’t been registered yet. The token is used in the header of requests that create a user, such as the Accept Invite API route.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
const token = await sdk.auth.register("user", "emailpass", {
email: "user@gmail.com",
password: "supersecret"
})
// all subsequent requests will use the token in the header
const { user } = await sdk.admin.invite.accept(
{
email: "user@gmail.com",
first_name: "John",
last_name: "Smith",
invite_token: "12345..."
},
){
"token": "<string>"
}The provider used for authentication.
"emailpass"
The input data necessary for authentication. For example, for email-pass authentication, pass email and password properties.
OK
The authentication's details.
The JWT token used for registration or authentication.