Skip to content

Get hoyoverse API token (Hoyolab Miyoushe)

zvyap edited this page Mar 4, 2024 · 7 revisions

Before start

Note

  1. Go to main page of the Hoyolab or for Mainland China Miyoushe
  2. Make sure you logged in into your account

Caution

Make sure you keep your token properly, leak of the token may cause your account got access by others.
Log out the Hoyolab AS FAST AS POSSIBLE if you realize your token leaked.

Proceed with Easy Way or Manual Way

Easy

Right click > Inspect

image

Select Console tab

image

Paste code below into your console

(()=>{if(document.cookie.includes('ltoken')&&document.cookie.includes('ltuid')){const e=document.createElement('input');try{e.value=`${t('ltuid')},${t('ltoken')}`}catch(o){console.warn('readCookie is still undefined');const t=e=>{const o=`; ${document.cookie}`.split(`; ${e}=`);if(2===o.length)return o.pop().split(';').shift()};e.value=`${t('ltuid')},${t('ltoken')}`}document.body.appendChild(e),e.select(),navigator.clipboard.writeText(e.value),prompt('Success! Token is copied to clipboard. You may manually copy the token below:\n',e.value)}else alert('Token has expired. Please signin again.')})();

Credit: https://gist.github.com/blueaxis/77847e63522fc747450ef718b68719ee


image

Press Enter


TADA~ You got the id and token

image

Note

Your id is on the left side of the comma (Red Highlight)
Your token is on the right side of the comma (Green Highlight)

Manual

Right click > Inspect

image

Select Application tab

image

Select the URL of the website in the Cookies section

image image

Search for ltuid and ltoken, copy the value down

Note: If ltuid & ltoken is not exist, use ltuid_v2 & ltoken_v2 instead, just copy all value in the cookie without any change

Note for developer: Use HoyoToken#of instead of manually create the HoyoToken object. If do, please make sure you are using the right object HoyoToken / HoyoTokenV2

image image

TADA~ You got the id and token