Use datasyncIdToken as poTokenIdentity
This commit is contained in:
1 parent
6a4a61b61f
commit
5e798f19de
12 files changed
+132
No files matched your search
@@ -28,6 +28,13 @@ namespace InnertubeService
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(accessToken)
|
||||
profileNode = OptionUtils.Get(options, "profileNode")
|
||||
if profileNode <> invalid
|
||||
options["datasyncIdToken"] = GetProfileDatasyncIdToken(profileNode, accessToken, OptionUtils.Get(options, "profilesService"), cancellation)
|
||||
end if
|
||||
end if
|
||||
|
||||
nextRequest = invalid
|
||||
if fetchNext
|
||||
nextRequest = Innertube.CreateNextRequest({ "videoId": videoId }, options)
|
||||
@@ -760,6 +767,39 @@ namespace InnertubeService
|
||||
return Innertube.ListAccounts(accessToken, cancellation)
|
||||
end function
|
||||
|
||||
function GetProfileDatasyncIdToken(profileNode as object, accessToken as string, profilesService as object, cancellation as object) as string
|
||||
endpoint = profileNode.selectActiveIdentityEndpoint
|
||||
if not IsAssociativeArray(endpoint) or endpoint.Count() = 0
|
||||
endpoint = BackfillSelectActiveIdentityEndpoint(profileNode, accessToken, profilesService, cancellation)
|
||||
end if
|
||||
return Innertube.GetDatasyncIdToken(endpoint)
|
||||
end function
|
||||
|
||||
function BackfillSelectActiveIdentityEndpoint(profileNode as object, accessToken as string, profilesService as object, cancellation as object) as object
|
||||
LogInfo("Backfilling selectActiveIdentityEndpoint for signed-in profile")
|
||||
accounts = Innertube.ListAccounts(accessToken, cancellation)
|
||||
if not IsArray(accounts)
|
||||
return invalid
|
||||
end if
|
||||
|
||||
for each account in accounts
|
||||
if account.activeIdentifyToken <> profileNode.activeIdentifyToken
|
||||
continue for
|
||||
end if
|
||||
endpoint = account.selectActiveIdentityEndpoint
|
||||
if IsAssociativeArray(endpoint) and endpoint.Count() > 0
|
||||
profileNode.selectActiveIdentityEndpoint = endpoint
|
||||
if profilesService <> invalid
|
||||
profilesService@.SaveUserProfilesToRegistry()
|
||||
end if
|
||||
return endpoint
|
||||
end if
|
||||
exit for
|
||||
end for
|
||||
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function GetDrmLicense(options as object) as dynamic
|
||||
request = Innertube.CreateGetDrmLicenceRequest(options)
|
||||
|
||||
|
||||
@@ -248,6 +248,7 @@ namespace Innertube
|
||||
"accountByline": ParseText(accountItem["accountByline"])
|
||||
"channelHandle": ParseText(accountItem["channelHandle"])
|
||||
"activeIdentifyToken": ParseAccountItemIdentityToken(accountItem)
|
||||
"selectActiveIdentityEndpoint": ValidAssociativeArray(ObjectUtils.Dig(accountItem, ["serviceEndpoint", "selectActiveIdentityEndpoint"]))
|
||||
}
|
||||
parsedAccounts.Push(parsedAccount)
|
||||
end for
|
||||
@@ -297,6 +298,26 @@ namespace Innertube
|
||||
return ""
|
||||
end function
|
||||
|
||||
function GetDatasyncIdToken(selectActiveIdentityEndpoint as object) as string
|
||||
supportedTokens = ObjectUtils.Dig(selectActiveIdentityEndpoint, ["supportedTokens"])
|
||||
if not IsArray(supportedTokens)
|
||||
return ""
|
||||
end if
|
||||
|
||||
for each supportedToken in supportedTokens
|
||||
if not IsAssociativeArray(supportedToken)
|
||||
continue for
|
||||
end if
|
||||
|
||||
datasyncIdToken = ObjectUtils.Dig(supportedToken, ["datasyncIdToken", "datasyncIdToken"])
|
||||
if not StringUtils.IsNullOrEmpty(datasyncIdToken)
|
||||
return datasyncIdToken
|
||||
end if
|
||||
end for
|
||||
|
||||
return ""
|
||||
end function
|
||||
|
||||
function ToCamelCase(obj as object) as object
|
||||
if not IsAssociativeArray(obj)
|
||||
return obj
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Innertube
|
||||
cancellation = OptionUtils.Get(options, "cancellation")
|
||||
visitorData = OptionUtils.Get(options, "visitorData")
|
||||
accessToken = OptionUtils.Get(options, "accessToken")
|
||||
datasyncIdToken = OptionUtils.Get(options, "datasyncIdToken")
|
||||
cpn = InnertubeService.CreateClientPlaybackNonce()
|
||||
|
||||
useAccessToken = (client = Innertube.ClientType.Tv or client = Innertube.ClientType.TvDowngraded) and not StringUtils.IsNullOrEmpty(accessToken)
|
||||
@@ -62,6 +63,8 @@ namespace Innertube
|
||||
if not StringUtils.IsNullOrEmpty(visitorData) and not useAccessToken
|
||||
request.Header("x-goog-visitor-id", visitorData)
|
||||
request.poTokenIdentity = visitorData
|
||||
else if useAccessToken and not StringUtils.IsNullOrEmpty(datasyncIdToken)
|
||||
request.poTokenIdentity = datasyncIdToken
|
||||
end if
|
||||
|
||||
request.signatureTimestamp = signatureTimestamp
|
||||
@@ -547,6 +550,7 @@ namespace Innertube
|
||||
if not StringUtils.IsNullOrEmpty(poTokenIdentity)
|
||||
body["identity"] = poTokenIdentity
|
||||
end if
|
||||
LogDebug("decipher poToken identity:", poTokenIdentity)
|
||||
|
||||
request = HttpClient.PostJson(`${PLAYLET_SUPPORT_SERVER}/v2/decipher`, body)
|
||||
request.Cancellation(cancellation)
|
||||
|
||||
@@ -58,6 +58,7 @@ function LoadProfilesFromRegistry()
|
||||
profileNode.accessToken = profile.accessToken
|
||||
|
||||
profileNode.activeIdentifyToken = profile.activeIdentifyToken
|
||||
profileNode.selectActiveIdentityEndpoint = profile.selectActiveIdentityEndpoint
|
||||
profileNode.refreshToken = profile.refreshToken
|
||||
profileNode.scope = profile.scope
|
||||
profileNode.tokenType = profile.tokenType
|
||||
@@ -182,6 +183,7 @@ function GetProfilesDto(includeAccessToken as boolean) as object
|
||||
profile["expiresTimestamp"] = profileNode.expiresTimestamp
|
||||
profile["clientId"] = profileNode.clientId
|
||||
profile["clientSecret"] = profileNode.clientSecret
|
||||
profile["selectActiveIdentityEndpoint"] = ValidAssociativeArray(profileNode.selectActiveIdentityEndpoint)
|
||||
end if
|
||||
|
||||
userProfiles.profiles.Push(profile)
|
||||
|
||||
Reference in new issue
Block a user