canaria3406/hoyolab-auto-sign

failed to get ltoken_v2, ltmid_v2 and ltuid_v2 from cookie

c436zhan opened this issue · 9 comments

After running the script, I am getting 'account_mid_v2=REDACTED; account_id_v2=REDACTED; ltoken_v2=undefined; ltmid_v2=undefined; ltuid_v2=undefined;'.
It seems that they are not in cookies?

Turns out that my ad blocker blocked ltmid_v2 and ltuid_v2. Still getting ltoken_v2 undefined after turning my ad block off. Same issue for my friend as well.

To get the token go to Honkai: Star Rail for example, in console type "document.cookie" and you get your cookie. If not, go to Network, and check "Preserve Log", reload the page, go pack to Console type that again and you should get it. That's what i did

Deses commented

Even worse, I'm getting account_mid_v2=undefined; account_id_v2=undefined; ltoken_v2=undefined; ltmid_v2=undefined; ltuid_v2=undefined;

🤷

Maybe it's because I'm using Brave or my HoyoLab is set to spanish.

Using Edge and with hoyolab in english worked. (it was like that using edge for some reason, I didn't change it)

Deses commented

I had to use https://chrome.google.com/webstore/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc/ to properly get ltoken_v2.

IDK why getCookie is not retrieving data correctly on any of my browsers. But it's good to know this workaround.

Deses commented

I logged out and back into HoyoLab and now my cookie has none of these values set:

account_mid_v2 account_id_v2 ltoken_v2 ltmid_v2 ltuid_v2

And now I have ltoken ltuid cookie_token account_id

Try :

function getCookie(name) {
  const value = `; ${document.cookie}`;
  const parts = value.split(`; ${name}=`);
  if (parts.length === 2) return parts.pop().split(';').shift();
}
let token = 'Error';
if (document.cookie.includes('ltoken=')) {
  token = 'ltoken=' + getCookie('ltoken') + '; ltuid=' + getCookie('ltuid') + ';';
} else if (document.cookie.includes('ltoken_v2=')) {
  token = 'account_mid_v2=' + getCookie('account_mid_v2') + '; account_id_v2=' + getCookie('account_id_v2') + '; ltoken_v2=' + getCookie('ltoken_v2') + '; ltmid_v2=' + getCookie('ltmid_v2') + '; ltuid_v2=' + getCookie('ltuid_v2') + ';';
}
let ask = confirm(token + '\n\nPress enter, then paste the token into your Google Apps Script Project');
if (ask == true) {
  copy(token);
  msg = token;
} else {
  msg = 'Cancel';
}

If you get ltoken, then use ltoken. If you get ltoken_v2, then use ltoken_v2.

Deses commented

I finally got an "OK" as a response using Google's AS with this updated script!

Today it got token = 'ltoken=' + getCookie('ltoken') + '; ltuid=' + getCookie('ltuid') + ';';

Maybe they reverted back to the "old" tokens.

Able to get the token now

its broken again.
i got to do it manually using filter and search lt