Auth Resource Documentation
Simulated JWT authentication endpoints (login, register, token refresh, profile read/update). Returns signed JWT access and refresh tokens linked to your session sandbox.
Authenticate user with username/email & password to receive signed JWT access and refresh tokens.
curl -X POST 'http://playground-api-xi.vercel.app/auth/login' \
-H 'Content-Type: application/json'
\
-b "pg_identity=your_cookie_uuid" \
-d '{
"username": "Bret",
"password": "password123"
}'
fetch('http://playground-api-xi.vercel.app/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ "username": "Bret", "password": "password123" })
})
.then(res => res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.post('http://playground-api-xi.vercel.app/auth/login', { "username": "Bret", "password": "password123" }, {
withCredentials: true
}).then(response => console.log(response.data));
import requests
payload = { "username": "Bret", "password": "password123" }
response =
requests.post('http://playground-api-xi.vercel.app/auth/login', json=payload)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url :=
"http://playground-api-xi.vercel.app/auth/login"
payload := []byte(`{ "username": "Bret", "password": "password123" }`)
req, err := http.NewRequest("POST",
url, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type",
"application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil
{
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/auth/login")!
var request = URLRequest(url:
url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let jsonString = """
{ "username": "Bret", "password": "password123" }
"""
request.httpBody = jsonString.data(using:
.utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data,
error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString ??
"")
}
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import
okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val mediaType = "application/json;
charset=utf-8".toMediaType()
val body = """{ "username": "Bret", "password": "password123" }""".toRequestBody(mediaType)
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/auth/login")
.post(body)
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client
= reqwest::Client::new();
let payload = json!({ "username": "Bret", "password": "password123" });
let response = client
.post("http://playground-api-xi.vercel.app/auth/login")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'http://playground-api-xi.vercel.app/auth/login', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => json_decode('{ "username": "Bret", "password": "password123" }', true)
]);
echo $response->getBody();
Request Payload Example
{
"username": "Bret",
"password": "password123"
}
โก Try it out โ Test endpoint live Test now
Register a new session user and immediately receive signed JWT tokens.
curl -X POST 'http://playground-api-xi.vercel.app/auth/register' \
-H 'Content-Type: application/json'
\
-b "pg_identity=your_cookie_uuid" \
-d '{
"name": "Alice Smith",
"username": "alice",
"email": "alice@example.com",
"password": "password123"
}'
fetch('http://playground-api-xi.vercel.app/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" })
})
.then(res => res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.post('http://playground-api-xi.vercel.app/auth/register', { "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" }, {
withCredentials: true
}).then(response => console.log(response.data));
import requests
payload = { "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" }
response =
requests.post('http://playground-api-xi.vercel.app/auth/register', json=payload)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url :=
"http://playground-api-xi.vercel.app/auth/register"
payload := []byte(`{ "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" }`)
req, err := http.NewRequest("POST",
url, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type",
"application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil
{
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/auth/register")!
var request = URLRequest(url:
url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let jsonString = """
{ "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" }
"""
request.httpBody = jsonString.data(using:
.utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data,
error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString ??
"")
}
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import
okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val mediaType = "application/json;
charset=utf-8".toMediaType()
val body = """{ "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" }""".toRequestBody(mediaType)
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/auth/register")
.post(body)
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client
= reqwest::Client::new();
let payload = json!({ "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" });
let response = client
.post("http://playground-api-xi.vercel.app/auth/register")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'http://playground-api-xi.vercel.app/auth/register', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => json_decode('{ "name": "Alice Smith", "username": "alice", "email": "alice@example.com", "password": "password123" }', true)
]);
echo $response->getBody();
Request Payload Example
{
"name": "Alice Smith",
"username": "alice",
"email": "alice@example.com",
"password": "password123"
}
โก Try it out โ Test endpoint live Test now
Exchange a valid refresh token for a fresh 15-minute JWT access token.
curl -X POST 'http://playground-api-xi.vercel.app/auth/refresh' \
-H 'Content-Type: application/json'
\
-b "pg_identity=your_cookie_uuid" \
-d '{
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..."
}'
fetch('http://playground-api-xi.vercel.app/auth/refresh', {
method: 'POST',
headers: {
'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." })
})
.then(res => res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.post('http://playground-api-xi.vercel.app/auth/refresh', { "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." }, {
withCredentials: true
}).then(response => console.log(response.data));
import requests
payload = { "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." }
response =
requests.post('http://playground-api-xi.vercel.app/auth/refresh', json=payload)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url :=
"http://playground-api-xi.vercel.app/auth/refresh"
payload := []byte(`{ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." }`)
req, err := http.NewRequest("POST",
url, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type",
"application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil
{
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/auth/refresh")!
var request = URLRequest(url:
url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let jsonString = """
{ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." }
"""
request.httpBody = jsonString.data(using:
.utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data,
error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString ??
"")
}
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import
okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val mediaType = "application/json;
charset=utf-8".toMediaType()
val body = """{ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." }""".toRequestBody(mediaType)
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/auth/refresh")
.post(body)
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client
= reqwest::Client::new();
let payload = json!({ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." });
let response = client
.post("http://playground-api-xi.vercel.app/auth/refresh")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'http://playground-api-xi.vercel.app/auth/refresh', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => json_decode('{ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..." }', true)
]);
echo $response->getBody();
Request Payload Example
{
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6..."
}
โก Try it out โ Test endpoint live Test now
Retrieve current authenticated user profile using Authorization: Bearer <access_token>.
curl -X
GET 'http://playground-api-xi.vercel.app/auth/me' \
-H 'Content-Type: application/json' \
-b "pg_identity=your_cookie_uuid"
fetch('http://playground-api-xi.vercel.app/auth/me', {
method: 'GET' ,
credentials: 'include'
})
.then(res=>
res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.get('http://playground-api-xi.vercel.app/auth/me', {
withCredentials: true
}).then(response =>
console.log(response.data));
import requests
response = requests.get('http://playground-api-xi.vercel.app/auth/me')
print(response.json())
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "http://playground-api-xi.vercel.app/auth/me"
req,
err := http.NewRequest("GET", url, nil)
if err != nil
{
panic(err)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp,
err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/auth/me")!
var request = URLRequest(url:
url)
request.httpMethod = "GET"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data =
data, error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString
?? "")
}
task.resume()
import okhttp3.OkHttpClient
import okhttp3.Request
val client = OkHttpClient()
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/auth/me")
.get()
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client =
reqwest::Client::new();
let response = client
.get("http://playground-api-xi.vercel.app/auth/me")
.header("Content-Type", "application/json")
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('GET', 'http://playground-api-xi.vercel.app/auth/me', [
'headers' => [
'Content-Type' => 'application/json'
]
]);
echo $response->getBody();
โก Try it out โ Test endpoint live Test now
Update current authenticated user profile in the session sandbox using Authorization: Bearer <access_token>.
curl -X PATCH 'http://playground-api-xi.vercel.app/auth/me' \
-H 'Content-Type: application/json'
\
-b "pg_identity=your_cookie_uuid" \
-d '{
"name": "Bret - Updated Profile",
"email": "bret.new@example.com"
}'
fetch('http://playground-api-xi.vercel.app/auth/me', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ "name": "Bret - Updated Profile", "email": "bret.new@example.com" })
})
.then(res => res.json())
.then(data => console.log(data));
import axios from 'axios';
axios.patch('http://playground-api-xi.vercel.app/auth/me', { "name": "Bret - Updated Profile", "email": "bret.new@example.com" }, {
withCredentials: true
}).then(response => console.log(response.data));
import requests
payload = { "name": "Bret - Updated Profile", "email": "bret.new@example.com" }
response =
requests.patch('http://playground-api-xi.vercel.app/auth/me', json=payload)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url :=
"http://playground-api-xi.vercel.app/auth/me"
payload := []byte(`{ "name": "Bret - Updated Profile", "email": "bret.new@example.com" }`)
req, err := http.NewRequest("PATCH",
url, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type",
"application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil
{
panic(err)
}
defer resp.Body.Close()
body, _ :=
io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import Foundation
let url = URL(string: "http://playground-api-xi.vercel.app/auth/me")!
var request = URLRequest(url:
url)
request.httpMethod = "PATCH"
request.setValue("application/json", forHTTPHeaderField:
"Content-Type")
let jsonString = """
{ "name": "Bret - Updated Profile", "email": "bret.new@example.com" }
"""
request.httpBody = jsonString.data(using:
.utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data,
error == nil else { return }
let responseString = String(data: data, encoding: .utf8)
print(responseString ??
"")
}
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import
okhttp3.RequestBody.Companion.toRequestBody
val client = OkHttpClient()
val mediaType = "application/json;
charset=utf-8".toMediaType()
val body = """{ "name": "Bret - Updated Profile", "email": "bret.new@example.com" }""".toRequestBody(mediaType)
val request =
Request.Builder()
.url("http://playground-api-xi.vercel.app/auth/me")
.patch(body)
.addHeader("Content-Type",
"application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
use reqwest::Error;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client
= reqwest::Client::new();
let payload = json!({ "name": "Bret - Updated Profile", "email": "bret.new@example.com" });
let response = client
.patch("http://playground-api-xi.vercel.app/auth/me")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('PATCH', 'http://playground-api-xi.vercel.app/auth/me', [
'headers' => [
'Content-Type' => 'application/json'
],
'json' => json_decode('{ "name": "Bret - Updated Profile", "email": "bret.new@example.com" }', true)
]);
echo $response->getBody();
Request Payload Example
{
"name": "Bret - Updated Profile",
"email": "bret.new@example.com"
}