Trang chủ / Tin tức / Hướng Dẫn Cấu Hình Google Login/Google OAuth 2.0 Setup Guide
Hướng dẫn 01/07/2026

Hướng Dẫn Cấu Hình Google Login/Google OAuth 2.0 Setup Guide

Hướng Dẫn Cấu Hình Google Login (Tiếng Việt)

Tài liệu này hướng dẫn chi tiết cách tạo và cấu hình dự án Google OAuth để phục vụ tính năng đăng nhập bằng Google trên website của bạn, sử dụng giao diện điều hướng mới của Google Cloud Console.

Bước 1: Tạo dự án mới (New Project)

  1. Truy cập trang chủ Google Cloud Console.
  2. Nhấn vào danh sách dự án ở góc trên cùng bên trái (bên cạnh logo Google Cloud) và chọn New Project (Dự án mới).
  3. Nhập tên dự án (ví dụ: ZTruyen Login) và nhấn Create (Tạo).
  4. Đợi vài giây để dự án được tạo, sau đó chọn dự án vừa tạo từ menu thả xuống ở góc trên cùng.

Bước 2: Cấu hình Branding (Màn hình đồng ý OAuth)

Đường dẫn cấu hình: Google Cloud Auth Branding

Đây là nơi bạn thiết lập thông tin hiển thị của ứng dụng với người dùng khi họ nhấn đăng nhập.

  1. Truy cập liên kết trên và chọn dự án của bạn (nếu được yêu cầu).
  2. Nếu hệ thống hỏi chọn User Type, hãy chọn External (Ngoài tổ chức) và nhấn Create.
  3. Điền các thông tin bắt buộc:
    • App name (Tên ứng dụng): Nhập tên hiển thị (ví dụ: ZTruyen).
    • User support email (Email hỗ trợ người dùng): Chọn email quản trị của bạn.
    • Developer contact information (Thông tin liên hệ nhà phát triển): Nhập email của bạn để nhận thông báo vận hành từ Google.
  4. LƯU Ý QUAN TRỌNG: Tuyệt đối KHÔNG tải logo lên ứng dụng (App logo) ở bước này nếu bạn không muốn gửi hồ sơ xác minh danh tính doanh nghiệp cho Google duyệt. Việc bỏ trống logo sẽ giúp tránh màn hình cảnh báo “Ứng dụng chưa được xác minh” khi người dùng đăng nhập.
  5. Điền thông tin App Domain: Thêm tên miền website của bạn (ví dụ: https://giaodienwp.net/) vào các trường: Application home page, Application privacy policy link, và mục Authorized domains.
  6. Nhấn Save and Continue (Lưu và tiếp tục).
  7. Ở phần Scopes (Phạm vi):
    • Nhấn Add or Remove Scopes.
    • Chọn các quyền cơ bản (không nhạy cảm) bao gồm: .../auth/userinfo.email, .../auth/userinfo.profile, và openid.
    • Nhấn Update -> chọn Save and Continue.

Bước 3: Cấu hình Audience và Kích hoạt Production

Đường dẫn cấu hình: Google Cloud Auth Audience

Mặc định ứng dụng sẽ ở trạng thái Testing (Thử nghiệm) và bị giới hạn người đăng nhập. Bạn cần đưa nó lên In Production (Chính thức).

  1. Truy cập đường dẫn trên.
  2. Tại mục Publishing status, nhấn nút PUBLISH APP (Xuất bản ứng dụng).
  3. Nhấn Confirm (Xác nhận).
  4. Trạng thái dự án sẽ chuyển sang In Production (Đang hoạt động). Bây giờ, mọi tài khoản Gmail đều có thể đăng nhập mà không bị giới hạn 100 người dùng.

Bước 4: Tạo Credentials (Thông tin xác thực Client)

Đường dẫn cấu hình: Google Cloud Auth Clients

Đây là bước tạo Client ID và Client Secret để nhập vào plugin WordPress của bạn.

  1. Truy cập đường dẫn trên.
  2. Nhấn nút Create Client (Tạo thông tin xác thực) -> chọn OAuth client ID.
  3. Tại mục Application type (Loại ứng dụng), chọn Web application (Ứng dụng web).
  4. Điền tên định danh (ví dụ: ZTruyen Web Client).
  5. Authorized JavaScript origins (Nguồn gốc JavaScript được ủy quyền): Nhập URL trang chủ website của bạn (ví dụ: https://quangtuyen.vn).
  6. Authorized redirect URIs (URI chuyển hướng được ủy quyền – Rất quan trọng): Nhập đường dẫn Callback nhận dữ liệu đăng nhập do Plugin WordPress cung cấp. Ví dụ: https://quangtuyen.vn/wp-login.php?loginSocial=google
  7. Nhấn Create (Tạo).
  8. Sao chép Client IDClient Secret vừa tạo để cấu hình vào Plugin trên website của bạn.

Google OAuth 2.0 Setup Guide (English)

This document provides step-by-step instructions to create and configure a Google OAuth project for Google Login on your website, using the new Google Cloud Console layout.

Step 1: Create a New Project

  1. Go to the Google Cloud Console.
  2. Click on the project dropdown at the top-left (next to the Google Cloud logo) and select New Project.
  3. Enter your project name (e.g., ZTruyen Login) and click Create.
  4. Wait a few seconds for creation, then select the new project from the top dropdown menu.

Step 2: Configure Branding (OAuth Consent Screen)

Configuration URL: Google Cloud Auth Branding

This configures what users see when they click the “Log in with Google” button on your site.

  1. Go to the URL above and select your project if prompted.
  2. If prompted for User Type, select External and click Create.
  3. Fill in the required fields:
    • App name: Enter the display name (e.g., ZTruyen).
    • User support email: Select your Gmail/Workspace email.
    • Developer contact information: Enter your email address to receive Google updates.
  4. IMPORTANT NOTE: Do NOT upload an App logo at this stage unless you are prepared to submit company registration documents to Google. Leaving the logo empty helps bypass the “Unverified App” warning screen during user logins.
  5. Fill in the App Domain details: Enter your website URL (e.g., https://giaodienwp.net/) in the Application home page, Application privacy policy link, and the Authorized domains list.
  6. Click Save and Continue.
  7. In the Scopes section:
    • Click Add or Remove Scopes.
    • Check basic non-sensitive scopes: .../auth/userinfo.email, .../auth/userinfo.profile, and openid.
    • Click Update, then Save and Continue.

Step 3: Configure Audience & Publish to Production

Configuration URL: Google Cloud Auth Audience

By default, your app is in Testing status. You must publish it to allow public logins.

  1. Go to the URL above.
  2. In the Publishing status section, click PUBLISH APP.
  3. Click Confirm.
  4. The status will update to In Production. Now, any Gmail user can sign in without the 100-user limit restriction.

Step 4: Create Client Credentials (Client IDs)

Configuration URL: Google Cloud Auth Clients

This generates the Client ID and Client Secret needed for your WordPress Google Login plugin.

  1. Go to the URL above.
  2. Click Create Client -> select OAuth client ID.
  3. Under Application type, select Web application.
  4. Enter a name for identification (e.g., ZTruyen Web Client).
  5. Authorized JavaScript origins: Enter your website homepage URL (e.g., https://giaodienwp.net/).
  6. Authorized redirect URIs: Enter the callback URI provided by your WordPress Google Login plugin (e.g., https://giaodienwp.net/wp-login.php?loginSocial=google).
  7. Click Create.
  8. Copy the generated Client ID and Client Secret and paste them into your WordPress website plugin settings.