import { OAuthDeviceAuthorizationResponse, OAuthTokenResponse } from '../Models/OAuth'; import axiosInstance from './axiosInstance'; export const deviceAuthorization = async (): Promise => { const api = axiosInstance(); const { data } = await api.post( '/oauth/device-authorize', { client_id: window.electron.clientId } ); return data; }; export const accessToken = async (deviceCode: string): Promise => { const api = axiosInstance(); const response = await api.post('/oauth/token', { grant_type: 'urn:ietf:params:oauth:grant-type:device_code', client_id: window.electron.clientId, device_code: deviceCode }, { baseURL: window.electron.url, headers: { 'Accept': 'application/json', } }); return response.data; }; export const refreshToken = async (refreshToken: string): Promise => { const api = axiosInstance(); const response = await api.post('/oauth/token', { grant_type: 'refresh_token', refresh_token: refreshToken, client_id: window.electron.clientId, }); return response.data; };