Personal Access Tokens (PAT)

GitHub เบื้องต้น

George Boorman

Curriculum Manager, DataCamp

การยืนยันตัวตน

  • สามารถใช้ Git ใน terminal เพื่อเชื่อมต่อกับ GitHub ได้
git clone https://github.com/george-boorman/bank_marketing
Username for 'https://github.com': george-boorman
Password for 'https://[email protected]':
GitHub เบื้องต้น

การยืนยันตัวตนล้มเหลว

 

 

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-
repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/george-boorman/bank_marketing/'
GitHub เบื้องต้น

GitHub Docs

หน้า GitHub Docs ที่แสดงคำแนะนำการใช้ personal access token (PAT) เมื่อรันคำสั่ง git clone, fetch, pull หรือ push ไปยัง remote repository

1 https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls
GitHub เบื้องต้น

Personal Access Token คืออะไร?

  • Personal Access Token (PAT)

    • ทางเลือกแทนการใช้รหัสผ่านสำหรับการยืนยันตัวตนใน terminal
    • บังคับใช้ตั้งแต่เดือนสิงหาคม 2021 แทนรหัสผ่าน
    • ปลอดภัยกว่า
  • ไม่จำเป็นต้องใช้ใน GitHub

    • ใช้เฉพาะเมื่อเข้าถึง remote repo ผ่าน terminal เท่านั้น
1 https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
GitHub เบื้องต้น

การสร้าง PAT

การเข้าถึงส่วน settings จากหน้าโปรไฟล์

GitHub เบื้องต้น

การสร้าง PAT

Developer settings ในหน้า settings

GitHub เบื้องต้น

การสร้าง PAT

หน้า Developer settings ที่มีสามตัวเลือก ได้แก่ GitHub Apps, OAuth Apps และ Personal access tokens

GitHub เบื้องต้น

การสร้าง PAT

ส่วน Personal access tokens พร้อมปุ่ม Generate new token

GitHub เบื้องต้น

การสร้าง PAT

ส่วน Note และ Expiration ของ PAT ใหม่

GitHub เบื้องต้น

การสร้าง PAT

การเลือก checkbox สิทธิ์เข้าถึง repo

GitHub เบื้องต้น

การสร้าง PAT

ปุ่ม Generate token

GitHub เบื้องต้น

การใช้ PAT

PAT ที่แสดงเป็นตัวอักษรและตัวเลขผสมกัน ซึ่งสามารถคัดลอกได้

GitHub เบื้องต้น

การใช้ PAT

PAT ที่ไฮไลต์เป็นตัวอักษรและตัวเลขผสมกัน ซึ่งสามารถคัดลอกได้

  • อย่าแชร์ PAT!
GitHub เบื้องต้น

การใช้ PAT

git clone https://github.com/george-boorman/bank_marketing
Cloning into 'bank_marketing'...
Username for 'https://github.com': george-boorman
Password for 'https://[email protected]':
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
ls
bank_marketing
GitHub เบื้องต้น

มาฝึกกันเถอะ!

GitHub เบื้องต้น

Preparing Video For Download...