Read-only mirror of github.com/smbcloudXYZ/smbcloud-ascapi.
Mirrored from https://github.com/smbcloudXYZ/smbcloud-ascapi.git
Synced Nov 25, 09:15 UTC
md
62 lines
2.53 KB
| 1 | # AdMob (`asc admob`) |
| 2 | |
| 3 | `asc admob` reads AdMob accounts, apps and ad units, and can create a rewarded |
| 4 | ad unit. It uses the AdMob API, which accepts user OAuth only. There are no |
| 5 | service accounts, so this is a one-time browser sign-in. |
| 6 | |
| 7 | ## One-time setup |
| 8 | |
| 9 | 1. In Google Cloud Console, pick a project and enable the **AdMob API**. |
| 10 | 2. Create an OAuth client of type **Desktop app** (APIs & Services, Credentials). |
| 11 | Configure the consent screen if asked; add yourself as a test user while |
| 12 | the screen is in testing. |
| 13 | 3. Download the client JSON and keep it outside any repo. |
| 14 | 4. Sign in as the Google user that owns the AdMob publisher account: |
| 15 | |
| 16 | ```bash |
| 17 | export ADMOB_OAUTH_CLIENT_JSON_PATH=~/path/to/client.json # or --admob-oauth-client |
| 18 | asc admob login |
| 19 | ``` |
| 20 | |
| 21 | The browser opens, Google redirects to a loopback port on `127.0.0.1`, and the |
| 22 | code is exchanged with PKCE. Only the refresh token is stored, at |
| 23 | `~/.config/asc/admob-token.json` with mode 0600. Later calls refresh access |
| 24 | tokens silently. Delete the file to sign out. Tokens and the client secret are |
| 25 | never printed. |
| 26 | |
| 27 | ## Commands |
| 28 | |
| 29 | ```bash |
| 30 | asc admob accounts |
| 31 | asc admob apps list [--account pub-...] |
| 32 | asc admob adunits list [--app ca-app-pub-...~...] [--account pub-...] |
| 33 | asc admob adunits create --app ca-app-pub-...~... --name "Karaoke rewarded" \ |
| 34 | --format rewarded --reward-amount 50 --reward-item Semitones |
| 35 | ``` |
| 36 | |
| 37 | `--account` defaults to the only account the user has. `--dry-run` on `create` |
| 38 | prints the request body and needs neither credentials nor a sign-in. After a |
| 39 | real create, `asc` reads the units back to confirm. If that read fails or the unit is not listed yet, the create still counts as done and the result carries a `warning`, so check `adunits list` before retrying. |
| 40 | |
| 41 | The MCP server exposes `admob_apps_list` and `admob_adunits_list`, both |
| 42 | read-only. They never open a browser; without a cached sign-in they say to run |
| 43 | `asc admob login`. |
| 44 | |
| 45 | ## Limited access on create |
| 46 | |
| 47 | `accounts.adUnits.create` (v1beta, scope `admob.monetization`) is limited |
| 48 | access. Without a grant from your AdMob account manager it answers **403**, and |
| 49 | `asc` reports that as a limited-access error. When that happens: |
| 50 | |
| 51 | 1. Create the unit in the console at |
| 52 | `https://admob.google.com/v2/apps/<numeric app id>/adunits/create`. |
| 53 | 2. Run `asc admob adunits list --app <appId>` to read its ID. |
| 54 | |
| 55 | ## What the API cannot do |
| 56 | |
| 57 | These stay manual console steps: |
| 58 | |
| 59 | - the server-side verification (SSV) callback URL on a rewarded unit |
| 60 | - GDPR / consent messages |
| 61 | - app-ads.txt verification |
| 62 | - Google Play's "Contains ads" and Data safety forms (those are Play Console) |