Đăng ký quyền truy cập sớm

Nhập tên của bạn cùng email hoặc số điện thoại. Chúng tôi sẽ liên hệ và gửi thông tin truy cập Tajo.

OAuth 2.0

OAuth 2.0 cung cấp cơ chế xác thực an toàn dựa trên token cho các ứng dụng bên thứ ba truy cập Brevo thay mặt người dùng.

Tổng quan luồng OAuth

  1. Yêu cầu ủy quyền: Chuyển hướng người dùng sang Brevo
  2. Người dùng ủy quyền: Người dùng cấp quyền truy cập
  3. Mã ủy quyền: Brevo chuyển hướng trở lại kèm theo mã
  4. Đổi lấy access token: Đổi mã ủy quyền lấy token
  5. Truy cập API: Dùng access token cho các yêu cầu

Endpoint ủy quyền

https://app.brevo.com/oauth/authorize?
response_type=code&
client_id=YOUR_CLIENT_ID&
redirect_uri=YOUR_REDIRECT_URI&
scope=email%20contacts&
state=random_string

Đổi lấy token

Terminal window
curl -X POST "https://api.brevo.com/v3/oauth/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code&code=AUTH_CODE&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&redirect_uri=YOUR_REDIRECT_URI"

Cách dùng access token

const response = await fetch('https://api.brevo.com/v3/account', {
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Accept': 'application/json'
}
});

Các scope

  • email: Gửi email giao dịch
  • contacts: Quản lý liên hệ và danh sách
  • campaigns: Tạo và gửi chiến dịch
  • sms: Gửi tin nhắn SMS
  • webhooks: Quản lý webhook

Làm mới token

const refreshToken = async () => {
const response = await fetch('https://api.brevo.com/v3/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'refresh_token',
refresh_token: 'YOUR_REFRESH_TOKEN',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET'
})
});
return response.json();
};

Đăng ký quyền truy cập sớm

Nhập tên của bạn cùng email hoặc số điện thoại. Chúng tôi sẽ liên hệ và gửi thông tin truy cập Tajo.

tự động nhận diện
Trợ lý AI

Xin chào! Hãy hỏi tôi về tài liệu.