Get a token
Yeah, this is the boring security stuff. Just get your super secret token and move on.
curl -X POST "https://galaxy.scalar.com/auth/token" \
-H "Content-Type: application/json" \
-d '{
"email": "marc@scalar.com",
"password": "i-love-scalar"
}'
const body = JSON.stringify({
"email": "marc@scalar.com",
"password": "i-love-scalar"
})
fetch("https://galaxy.scalar.com/auth/token", {
body
})
package main
import (
"fmt"
"net/http"
"io/ioutil"
"strings"
)
func main() {
url := "https://galaxy.scalar.com/auth/token"
body := strings.NewReader(`{
"email": "marc@scalar.com",
"password": "i-love-scalar"
}`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import requests
url = "https://galaxy.scalar.com/auth/token"
body = {
"email": "marc@scalar.com",
"password": "i-love-scalar"
}
response = requests.request("POST", url, json = body, headers = {
"Content-Type": "application/json"
})
print(response.text)
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
{
"type": "https://example.com/errors/bad-request",
"title": "Bad Request",
"status": 400,
"detail": "The request was invalid."
}
{
"type": "https://example.com/errors/not-found",
"title": "Unauthorized",
"status": 401,
"detail": "You are not authorized to access this resource."
}
{
"type": "https://example.com/errors/forbidden",
"title": "Forbidden",
"status": 403,
"detail": "You are not authorized to access this resource."
}
How is this guide?