fix oauth

This commit is contained in:
lendry
2026-06-26 09:20:06 +03:00
parent a15be4365c
commit 971d10abf6
3 changed files with 96 additions and 44 deletions

View File

@@ -407,6 +407,18 @@ export async function fetchAuthSession(token?: string | null): Promise<AuthSessi
return apiFetch<AuthSessionResponse>('/auth/session', {}, token);
}
export async function approveOAuthAuthorization(params: URLSearchParams, token: string) {
const query = new URLSearchParams();
params.forEach((value, key) => {
if (key !== 'userId') query.set(key, value);
});
return apiFetch<{ redirectUrl?: string }>(
`/oauth/authorize?${query.toString()}`,
{ headers: { Accept: 'application/json' } },
token
);
}
export async function refreshAuthSession(): Promise<RefreshSessionResponse> {
if (typeof window === 'undefined') {
throw new ApiError('Refresh token недоступен на сервере', 401, 'NO_REFRESH');