Authenticates a customer with email/password and returns a JWT token
JavaScript
import { createClient } from '@spree/sdk' const client = createClient({ baseUrl: 'https://your-store.com', publishableKey: '<api-key>', }) const auth = await client.auth.login({ email: 'customer@example.com', password: 'password123', })
{ "token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6IjkxOGY5MzI4LWI0YzctNDU5Yi1iZTczLTIxMzMwZDhhMmM5YSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzc0NzAxODQ4fQ.cuuj2Oi6xGSBeNEYjr91DrFNQrWTvyTaTHTbXDhdeOQ", "refresh_token": "YGoDXXid6KGaL59iez28EoWL", "user": { "id": "cus_UkLWZg9DAJ", "email": "test@example.com", "first_name": "Jolynn", "last_name": "Stiedemann", "phone": null, "accepts_email_marketing": false, "available_store_credit_total": "0", "display_available_store_credit_total": "$0.00", "addresses": [], "default_billing_address": null, "default_shipping_address": null } }
Publishable API key for store access
"customer@example.com"
"password123"
Authentication provider (default: email)
"email"
login successful
JWT access token
Refresh token for obtaining new access tokens
Show child attributes
Was this page helpful?