完成后,系统会显示一个 OAuth 2.0 客户端 ID 和客户端密钥,您可以将其下载为 JSON 格式进行保存,以备日后使用。
发出请求
AdMob API 是基于 HTTP 和 JSON 构建的,因此任何标准 HTTP 客户端均可向其发送请求并解析响应。不过,使用 Google API 客户端库将为您带来优势,例如语言集成更出色、安全性更高,且支持发出经过授权的请求。客户端库支持多种编程语言;使用客户端库可以避免手动设置 HTTP 请求和手动解析响应。
创建 OAuth 2.0 凭据后,您便可以开始使用 AdMob API 了。如需使用 OAuth 2.0 请求访问权限,您的应用还需要提供范围信息:
[null,null,["最后更新时间 (UTC):2024-11-08。"],[[["This guide helps developers programmatically access AdMob account data using the AdMob API, requiring OAuth2 authorization for secure interactions."],["Before starting, ensure you have a Google Account, an AdMob account, and familiarity with REST basics and OAuth 2.0 authorization."],["Choose the appropriate authentication type (Desktop or Web app) based on your app's needs and authorization process."],["Create or select a Google API project and enable the AdMob API to get started, then generate OAuth2 credentials for authorization."],["Make your first API request using provided code examples (Java, PHP, Python, or curl) and manage token revocation for security."]]],["To use the AdMob API, developers must authorize requests via OAuth2. Key actions include creating a project in the Google API Console and enabling the AdMob API. Developers then generate OAuth2 credentials, choosing between desktop or web app authentication types. The OAuth consent screen must be configured. Finally, with created credentials and specifying the scope (`admob.readonly` or `admob.report`), developers can use HTTP or Google API client libraries to make their first API request and start retrieving AdMob data. Shared tokens can be revoked.\n"]]