A vanilla Node.js example for the Yoto API that uses device login flow and lists your cards
-
Install dependencies:
npm install
-
Create a .env file:
echo "YOTO_CLIENT_ID=your_client_id_here" > .env
Run the example:
npm startOn your first run, you'll see something like:
=========================
No saved authentication found. Starting device login...
┌─────────────────────────────┬──────────────────────────────────────────────────────────────┐
│ verification_uri │ https://login.yotoplay.com/activate │
├─────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ verification_uri_complete │ https://login.yotoplay.com/activate?user_code=ABCD-EFGH │
├─────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ user_code │ ABCD-EFGH │
├─────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ expires_in_minutes │ 5 │
└─────────────────────────────┴──────────────────────────────────────────────────────────────┘
- Visit the verification URL or scan the QR code (if you have one)
- Enter the user code when prompted
- Complete the authentication on your device
- The script will automatically continue and show your cards
After the first authentication, the refresh token is saved locally, so subsequent runs will use the saved authentication and go straight to listing your cards.