import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000"
if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}
export const sdk = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
debug: process.env.NODE_ENV === "development",
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})
const token = await sdk.auth.refresh()
// all subsequent requests will use the token in the header
const { customer } = await sdk.store.customer.retrieve()
{
"token": "<string>"
}
Refresh the authentication token of a customer. This is useful after authenticating a customer with a third-party service to ensure the token holds the new user’s details, or when you don’t want customers to re-login every day.
import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000"
if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}
export const sdk = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
debug: process.env.NODE_ENV === "development",
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})
const token = await sdk.auth.refresh()
// all subsequent requests will use the token in the header
const { customer } = await sdk.store.customer.retrieve()
{
"token": "<string>"
}
OK
The authentication's details.