Implemented googleapi access token refresher

This commit is contained in:
Eclypsed
2024-02-17 00:31:11 -05:00
parent 416803af81
commit 85a17dcd89
6 changed files with 84 additions and 55 deletions

View File

@@ -100,4 +100,24 @@ export class Jellyfin {
thumbnail,
}
}
static connectionInfo = async (connection: Jellyfin.JFConnection): Promise<ConnectionInfo> => {
const reqHeaders = new Headers({ Authorization: `MediaBrowser Token="${connection.tokens.accessToken}"` })
const userUrl = new URL(`Users/${connection.service.userId}`, connection.service.urlOrigin).href
const systemUrl = new URL('System/Info', connection.service.urlOrigin).href
const userResponse = await fetch(userUrl, { headers: reqHeaders })
const systemResponse = await fetch(systemUrl, { headers: reqHeaders })
const userData: Jellyfin.User = await userResponse.json()
const systemData: Jellyfin.System = await systemResponse.json()
return {
connectionId: connection.id,
serviceType: 'jellyfin',
username: userData.Name,
serverName: systemData.ServerName,
}
}
}