9. Xây CLI client (devcli login)

9 thẻ

Review deck này
Tất cả thẻ trong deck

Bước 1

Gọi device authorization endpoint, nhận device_code, user_code, verification_uri, expires_in, interval.

Bước 2

In user_code và URL, thử mở trình duyệt với verification_uri_complete nếu có.

Bước 3

Polling token endpoint mỗi `interval` giây, tăng 5 giây mỗi khi nhận `slow_down`.

Bước 4

Nhận token thì lưu vào keychain, fallback file 0600, rồi in tài khoản đã đăng nhập.

Dừng polling khi

Nhận token, `access_denied`, `expired_token`, quá `expires_in`, hoặc người dùng nhấn Ctrl+C.

Không in token ra terminal

Tránh lộ qua scrollback, log CI, screen sharing.

devcli whoami

Gọi API userinfo bằng access token, in tài khoản, team đang chọn và nguồn credential.

devcli logout

Revoke refresh token ở server rồi xoá credential local, kể cả khi revoke lỗi mạng.

Tôn trọng proxy và CA của doanh nghiệp

CLI nên đọc cấu hình proxy chuẩn để login chạy được sau firewall.

9. Xây CLI client (devcli login) – Flashcards – CLI Auth | Học Dev