รับข้อมูลจาก Google Cloud
มะนาวใช้ YouTube Data API v3 เพื่ออ่านแชทจาก YouTube Live ซึ่งต้องมี OAuth 2.0 credentials จาก Google Cloud Console ก่อน
สร้าง Google Cloud Project
Section titled “สร้าง Google Cloud Project”- เข้าไปที่ console.cloud.google.com
- กด Select a project → New Project
- ตั้งชื่อ project อะไรก็ได้ แล้วกด Create
เปิด YouTube Data API v3
Section titled “เปิด YouTube Data API v3”- ไปที่ APIs & Services → Library
- ค้นหา YouTube Data API v3
- กด Enable
สร้าง OAuth 2.0 Credentials
Section titled “สร้าง OAuth 2.0 Credentials”- ไปที่ APIs & Services → Credentials
- กด + Create Credentials → OAuth client ID
- ถ้ายังไม่ได้ตั้งค่า OAuth consent screen จะมีให้ตั้งก่อน:
- เลือก External
- กรอกชื่อ app (อะไรก็ได้)
- กรอก email ของตัวเอง
- กด Save and Continue จนครบ
- กลับมาสร้าง credentials ต่อ เลือก Application type: Desktop app
- ตั้งชื่ออะไรก็ได้ แล้วกด Create
- จะได้ Client ID และ Client Secret มา
เพิ่ม Test User
Section titled “เพิ่ม Test User”เนื่องจาก app ยังไม่ผ่าน Google verification ต้องเพิ่มตัวเองเป็น test user ก่อน:
- ไปที่ APIs & Services → OAuth consent screen
- เลื่อนลงมาที่ Test users
- กด + Add users
- เพิ่ม email ของ Google account ที่เชื่อมกับ YouTube channel ของเรา
- กด Save
ตั้งค่าใน Setup Wizard
Section titled “ตั้งค่าใน Setup Wizard”นำ Client ID และ Client Secret ไปกรอกในหน้า YouTube ของ Setup Wizard แล้วกด Authorize YouTube Account ได้เลย browser จะเปิดหน้า Google login ให้อัตโนมัติ ไม่ต้องกรอก redirect URI เพิ่มเติมใด ๆ