Bắt đầu
Xác thực
Một số thao tác của API này có thể truy cập công khai và không yêu cầu xác thực. Tuy nhiên, tất cả các thao tác ảnh hưởng đến tài khoản của bạn đều yêu cầu personal access token (PAT) hoặc OAuth authentication khi sử dụng ứng dụng bên thứ ba.
Personal Access Tokens
Cách dễ nhất để truy cập API là sử dụng personal access token (PAT) được tạo từ cổng Cloud Manager của Akamai. Token này chỉ nên có quyền truy cập cần thiết cho ứng dụng.
Cách tạo PAT
- Đăng nhập Cloud Manager.
- Nhấn vào tên hồ sơ của bạn ở góc trên bên phải và chọn API Tokens.
- Nhấp Create a Personal Access Token. Bảng tạo PAT xuất hiện..
- Điền Label, Expiry, Access.
- Nhấp Create Token. Token chỉ hiển thị một lần.
PAT authentication
Security Scheme Type | HTTP |
Authorization Scheme | Bearer |
Scopes OAuth cũng áp dụng cho PAT.
Thu hồi PAT
Đăng nhập Cloud Manager → My Profile → API Tokens, chọn token → Revoke.
OAuth
Nếu ứng dụng cần cho người dùng bất kỳ đăng nhập, hãy dùng OAuth 2.0.
Trước khi bắt đầu
- Tạo OAuth client để lấy
client_id
,client_secret
. - Private client dùng cho app bảo mật, Public client dùng cho app không thể giữ bí mật.
redirect_uri
là Callback URL.
Luồng Private (Authorization Code)
- User đăng nhập qua login.linode.com.
- Server trả về code qua redirect.
- App POST tới
/oauth/token
với code, client_id, secret. - Nhận access_token (2h) và refresh_token.
- Dùng access_token cho API call.
- Khi hết hạn, dùng refresh_token để lấy token mới.
Luồng Public (Implicit)
User đăng nhập và nhận access_token
qua URL hash (2h). Không có refresh_token, cần login lại sau khi hết hạn.
OAuth reference
Authorization URL: https://login.linode.com/oauth/authorize
Token URL: https://login.linode.com/oauth/token
Scopes
Scope | Mô tả |
---|---|
account:read_only | Xem thông tin tài khoản |
account:read_write | Quản lý tài khoản |
linodes:read_only | Xem Linodes |
linodes:read_write | Quản lý Linodes |
domains:read_only | Xem tên miền |
domains:read_write | Quản lý tên miền |
images:read_only | Xem images |
images:read_write | Quản lý images |
firewall:read_only | Xem firewalls |
firewall:read_write | Quản lý firewalls |
object_storage:read_only | Xem Object Storage |
object_storage:read_write | Quản lý Object Storage |
vpc:read_write | Quản lý VPC và subnet |
Xác thực Monitor API
- Gọi List supported services → lấy service_type.
- Gọi List cho service → lấy id.
- Gọi Create a token với service_type và entity_id → lưu token.
- Gọi Get metrics với Bearer token.
curl --request POST \
--url https://monitor-api.linode.com/v1/monitor/services/dbaas/metrics \
--header 'accept: application/json' \
--header 'authorization: Bearer abc123' \
--header 'content-type: application/json' \
--data '{"aggregate_function":"min"}'