26 lines
1013 B
Plaintext
26 lines
1013 B
Plaintext
import "pkg:/components/Services/Innertube/InnertubeService.bs"
|
|
import "pkg:/source/utils/ErrorUtils.bs"
|
|
|
|
@job("ProfileRefreshTokenJob")
|
|
function ExecuteJob() as void
|
|
input = JobGetInput()
|
|
profileNode = input.profile
|
|
accessTokenObject = input.accessTokenObject
|
|
profilesService = input.profilesService
|
|
try
|
|
cancellation = JobGetCancellation()
|
|
if InnertubeService.AuthRefreshAccessToken(accessTokenObject, cancellation)
|
|
profileNode.expiresIn = accessTokenObject.expiresIn
|
|
profileNode.expiresTimestamp = accessTokenObject.expiresTimestamp
|
|
profileNode.accessToken = accessTokenObject.accessToken
|
|
profilesService@.SaveUserProfilesToRegistry()
|
|
else
|
|
JobError("Failed to refresh access token")
|
|
profileNode.accessToken = invalid
|
|
end if
|
|
catch error
|
|
JobError("Failed to refresh access token: " + ErrorUtils.Format(error))
|
|
profileNode.accessToken = invalid
|
|
end try
|
|
end function
|