Authentication examples
Copy-paste auth requests in multiple languages.
Self-hosted base URL
Use the API base URL
Use these examples to request a JWT for user-scoped endpoints.
fetch('https://your-moonbase-host/api/auth/user', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
username: 'YOUR_USERNAME',
password: 'YOUR_PASSWORD',
hwid: 'OPTIONAL_HWID'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));