集成指南
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
获取私钥
使用初始配置界面
如需与该 API 集成,您必须创建一个 Google Cloud 项目。之后,创建服务账号并获取私钥。如需开始,请点击以下按钮:
创建服务账号
手动生成密钥
如果上述接口失败,请尝试以下操作:
- 前往 Google Cloud 控制台。
- 选择将用于访问 API 的项目。
- 在左侧的“IAM 和管理”菜单下,找到服务账号,然后创建一个将成为项目所有者的新服务账号。
- 创建服务账号后,您应该会收到一个私钥。
将服务账号列入白名单
创建服务账号后:
- 请使用项目所有者的 Google 账号发送电子邮件至 mdp-support@google.com,与 GTAF 团队联系。我们会将 Google 账号列入白名单,以便其访问 Mobile Data Plan Sharing API 端点。
- 在 Google ISP 门户上将服务账号与运营商相关联。运营商可以前往 API 访问权限来建立此关联。
启用媒体库
进入许可名单后:
- 访问Google云端控制台。
- 确保您已在顶部菜单栏的下拉菜单中选择正确的项目。
- 在 API 库中启用 Mobile Data Plan Sharing API。
- 在 API 库中启用 Preprod Mobile Data Plan Sharing API。
测试 API 访问权限
如需测试您对 Google 端方法的访问权限,请执行以下操作:
- 安装
oauth2l
。
按如下方式获取服务账号的访问令牌。
your-service-account-key-file.json
是服务账号的密钥文件。
> oauth2l fetch --json your-service-account-key-file.json dataplansharing
请注意,访问令牌会在大约一小时后过期。在为新访问令牌再次运行上述命令之前,请先运行 oauth2l reset
以清除本地缓存。
按如下方式发出测试调用。YOUR-ASN
必须是我们在集成过程中配置 GTAF 时您发送给我们的 ASN 之一。ACCESS-TOKEN-OBTAINED
是上述 oauth2l fetch
命令的输出。
PLAN_STATUS 是您要发送给 GTAF 的 PlanStatus 请求正文。
> url_domain="mobiledataplansharing.googleapis.com"
> url_path="v1/operators/YOUR-ASN/clients/mobiledataplan/users/USER_KEY/planStatus"
> curl -H "Content-Type: application/json" \
-d 'PLAN_STATUS' \
-X POST "https://$url_domain/$url_path?access_token=ACCESS-TOKEN-OBTAINED"
程序化 API 调用
按照说明使用以下 OAuth 范围对 Google 端方法进行授权调用:
https://www.googleapis.com/auth/dataplansharing
共享项目所有权
虽然初始设置只涉及一个 Google 账号,但最好让一组授权用户拥有项目的所有权。在 Google Cloud 控制台的“IAM 和管理”菜单下,您可以添加新成员(包括 Google 群组账号)作为项目的所有者。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[[["To integrate with the API, create a Google Cloud Project, a service account, and obtain a private key, potentially using the provided onboarding interface or manual steps."],["Whitelist the service account by contacting the GTAF team and associating it with the carrier on the Google ISP Portal for API access."],["Enable the necessary Mobile Data Plan Sharing APIs (both production and preprod) within your Google Cloud Project."],["Test API access using `oauth2l` to obtain an access token and make authorized calls with the specified OAuth scope."],["Share project ownership by adding members or Google Groups to the project in Google Cloud Console under IAM & admin."]]],["To access the API, create a Google Cloud Project, then create a service account and obtain its private key. Whitelist the associated Google account by contacting the GTAF team. Associate the service account with the carrier on the Google ISP Portal. Enable both Mobile Data Plan Sharing APIs in the Google Cloud Console. Test API access by installing `oauth2l` and obtaining an access token. Finally, you can share the project ownership with others from the Google Cloud Console.\n"]]