feat: authentication integration

This commit is contained in:
2025-05-28 20:51:34 +02:00
parent a1ed1113d9
commit aa152a4127
26 changed files with 1371 additions and 662 deletions

View File

@ -1,25 +1,25 @@
import { handleApiError } from ".";
import { handleApiError, axios } from ".";
export interface CodeResponse {
code: string;
}
export const codeApi = async (accessToken: string, nonce: string) => {
const response = await fetch("/api/v1/oauth/code", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
nonce,
}),
});
const response = await axios.post(
"/api/v1/oauth/code",
{ nonce },
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
}
);
if (response.status !== 200 && response.status !== 201)
throw await handleApiError(response);
const data: CodeResponse = await response.json();
const data: CodeResponse = response.data;
return data;
};