Ủy quyền
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Mọi yêu cầu mà ứng dụng của bạn gửi tới API AdMob đều phải bao gồm mã uỷ quyền. Mã này cũng giúp Google xác định ứng dụng của bạn.
Giới thiệu về giao thức cấp phép
Ứng dụng của bạn phải sử dụng OAuth 2.0 để cấp phép các yêu cầu. Chúng tôi không hỗ trợ giao thức cấp phép nào khác. Nếu ứng dụng của bạn sử dụng chức năng Đăng nhập bằng Google, thì Google sẽ giúp bạn xử lý một số bước trong quá trình cấp phép.
Cấp phép cho các yêu cầu bằng OAuth 2.0
Tất cả các yêu cầu đối với API AdMob phải do người dùng đã xác thực thực hiện.
Quá trình này được hỗ trợ bằng mã ứng dụng khách OAuth.
Nhận mã ứng dụng khách OAuth
Hoặc tạo một mã trong trang Thông tin xác thực.
Các chi tiết của quy trình cấp phép đối với OAuth 2.0 sẽ khác nhau đôi chút tuỳ thuộc vào loại ứng dụng bạn đang viết. Quy trình chung sau đây áp dụng cho tất cả các loại ứng dụng:
- Khi cần quyền truy cập vào dữ liệu người dùng, ứng dụng sẽ yêu cầu Google cung cấp phạm vi truy cập cụ thể.
- Google hiển thị màn hình yêu cầu sự đồng ý cho người dùng để hỏi xem họ có cho phép ứng dụng của bạn yêu cầu một số dữ liệu của họ hay không.
- Nếu người dùng đồng ý, thì Google sẽ cấp cho ứng dụng của bạn một mã truy cập ngắn hạn.
- Sau đó, ứng dụng yêu cầu dữ liệu người dùng và đính kèm mã truy cập trong yêu cầu.
- Nếu xác định rằng yêu cầu của bạn và mã này là hợp lệ, Google sẽ trả về dữ liệu mà ứng dụng yêu cầu.
Một số quy trình cấp phép có các bước bổ sung khác, chẳng hạn như sử dụng mã làm mới để lấy mã truy cập mới. Để biết thông tin chi tiết về quy trình cho các loại ứng dụng khác nhau, hãy xem tài liệu về OAuth 2.0 của Google.
Dưới đây là thông tin về phạm vi truy cập OAuth 2.0 cho API AdMob:
Phạm vi |
Ý nghĩa |
https://www.googleapis.com/auth/admob.readonly |
Xem tất cả dữ liệu AdMob. Dữ liệu này có thể bao gồm thông tin tài khoản, chế độ cài đặt về khoảng không quảng cáo cũng như chức năng dàn xếp, báo cáo và các dữ liệu khác.
Tuy nhiên, nữ liệu này không bao gồm dữ liệu nhạy cảm (chẳng hạn như thông tin về thanh toán hoặc thông tin chiến dịch).
|
https://www.googleapis.com/auth/admob.report |
Xem báo cáo về thu nhập và hiệu suất của quảng cáo. Xem mã nhà xuất bản,
múi giờ và mã đơn vị tiền tệ mặc định.
|
Để yêu cầu quyền truy cập bằng OAuth 2.0, ứng dụng của bạn cần thông tin về mức truy cập, cũng như thông tin mà Google cung cấp khi bạn đăng ký ứng dụng của mình (chẳng hạn như mã ứng dụng khách và mật khẩu ứng dụng khách).
Mẹo: Thư viện ứng dụng API Google có thể xử lý một số bước trong quy trình cấp phép cho bạn. Thư viện này được cung cấp bằng nhiều ngôn ngữ lập trình. Hãy xem trang về các thư viện và mẫu để biết thêm chi tiết.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-31 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eEvery AdMob API request requires an authorization token for application identification and user data access.\u003c/p\u003e\n"],["\u003cp\u003eAdMob API exclusively supports OAuth 2.0 for authorization, requiring applications to obtain user consent and access tokens.\u003c/p\u003e\n"],["\u003cp\u003eApplications need an OAuth client ID and specific scopes to request access to AdMob data like account information or reports.\u003c/p\u003e\n"],["\u003cp\u003eGoogle provides client libraries to simplify the authorization process across various programming languages.\u003c/p\u003e\n"]]],["All AdMob API requests require an OAuth 2.0 authorization token, obtainable via an OAuth client ID. The application requests a specific access scope, which prompts Google to display a consent screen to the user. Upon approval, Google grants a short-lived access token. The application then uses this token to request data. Access scopes include `admob.readonly` for general data and `admob.report` for performance reports. Google APIs client libraries can help manage parts of the process.\n"],null,["# Authorization\n\nEvery request your application sends to the AdMob API must include an authorization token. The token also identifies your application to Google.\n\n#### About authorization protocols\n\nYour application must use [OAuth 2.0](https://developers.google.com/identity/protocols/OAuth2) to authorize requests. No other authorization protocols are supported. If your application uses [Sign In With Google](https://developers.google.com/identity/gsi/web), some aspects of authorization are handled for you.\n\n#### Authorizing requests with OAuth 2.0\n\nAll requests to the AdMob API must be authorized by an authenticated user.\n\nThis process is facilitated with an OAuth client ID.\nGet an OAuth client ID\n\nOr create one in the [Credentials page](https://console.cloud.google.com/apis/credentials).\n\nThe details of the authorization process, or \"flow,\" for OAuth 2.0 vary somewhat depending on what kind of application you're writing. The following general process applies to all application types:\n\n1. When your application needs access to user data, it asks Google for a particular **scope** of access.\n2. Google displays a **consent screen** to the user, asking them to authorize your application to request some of their data.\n3. If the user approves, then Google gives your application a short-lived **access token**.\n4. Your application requests user data, attaching the access token to the request.\n5. If Google determines that your request and the token are valid, it returns the requested data.\n\nSome flows include additional steps, such as using **refresh tokens** to acquire new access tokens. For detailed information about flows for various types of applications, see Google's [OAuth 2.0 documentation](https://developers.google.com/identity/protocols/OAuth2).\n\nHere's the OAuth 2.0 scope information for the AdMob API:\n\n| Scope | Meaning |\n|--------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `https://www.googleapis.com/auth/admob.readonly` | See all AdMob data. This may include account information, inventory and mediation settings, reports, and other data. This doesn't include sensitive data, such as payments or campaign details. |\n| `https://www.googleapis.com/auth/admob.report` | See ad performance and earnings reports. See publisher ID, timezone, and default currency code. |\n\nTo request access using OAuth 2.0, your application needs the scope information, as well as\ninformation that Google supplies when you register your application (such as the client ID and the\nclient secret).\n\n**Tip:** The Google APIs client libraries can handle some of the authorization process for you. They are available for a variety of programming languages; check the [page with libraries and samples](/admob/api/v1/libraries) for more details."]]