Ns find gpc credentials

From Melvynx/saveit.now · View interactive version

Ns find gpc credentials is an AI agent skill from the GitHub repository Melvynx/saveit.now. Find and set up Google Play Console service-account JSON credentials for gpc. Use when Android Play uploads need auth, GPC_SERVICE_ACCOUNT is unknown, or before ns-deploy-android-app/ns-android-beta.

How to use this skill

Skill file

Find Google Play Console Credentials

<objective>

gpc auth login needs a Google service-account JSON key, a Play Console app/package, and Play Console permissions for that service-account email. This skill finds or creates the JSON, stores it in the repo-ignored NowStack path, and verifies that gpc can access dev.melvynx.nowstack.

Key insight from the NowStack Android setup: this is a two-console credential. Google Cloud owns the service account and JSON key; Google Play Console owns app access. A Cloud project alone is not enough. The service-account email must be invited in Play Console -> Users and permissions with app-scoped release permissions.

Terminology: gpc here means the Google Play Console CLI used by this repo. gcp means Google Cloud Platform, where the service account is created.

</objective>

<nowstack_state>

Known NowStack values:

| Value | Current value |

| --- | --- |

| Android package | dev.melvynx.nowstack |

| Runtime credential path | mobile-app/google-play-service-account.json |

| Git ignore status | mobile-app/google-play-service-account.json is ignored |

| Android deploy skill | .agents/skills/ns-deploy-android-app/SKILL.md |

| Observed download candidate | ~/Downloads/play-publisher-500306-d28739223973.json |

Treat observed downloads as candidates only. Verify JSON structure before using them.

</nowstack_state>

<credentials_anatomy>

| Credential | What it looks like | Where it lives |

| --- | --- | --- |

| Service-account JSON | JSON with type: "service_account", project_id, private_key_id, private_key, client_email | User disk; Downloads first, then repo ignored runtime path |

| Client email | <name>@<project-id>.iam.gserviceaccount.com | Inside the JSON; this is what Play Console must invite |

| Cloud project ID | e.g. play-publisher-500306 | Inside the JSON; API must be enabled here |

| Android package | dev.melvynx.nowstack | site-config.ts > androidPackage, Expo android.package, Play Console app |

| Developer ID | long numeric ID in Play Console URLs | Optional; useful for debugging account selection |

Look-alikes that are NOT Play publishing credentials:

</credentials_anatomy>

<step n="1" title="Check if gpc already works">

From the repo root:

command -v gpc && gpc --version
export GPC_APP="dev.melvynx.nowstack"
test -f mobile-app/google-play-service-account.json && export GPC_SERVICE_ACCOUNT="$PWD/mobile-app/google-play-service-account.json"
gpc doctor || true
gpc status || true

If gpc doctor and a read-only gpc status work for dev.melvynx.nowstack, stop. The credential is already usable.

</step>

<step n="2" title="Hunt for service-account JSON files">

Search standard locations first. Use jq to avoid mistaking random JSON files for credentials:

find "$HOME/Downloads" "$HOME/Desktop" "$HOME/Documents" "$HOME/Developer" "$HOME/.config/gcloud" \
  -maxdepth 6 -type f -name "*.json" -size -2M 2>/dev/null |
while IFS= read -r file; do
  jq -e '
    .type == "service_account"
    and (.client_email | test("@.*\\.iam\\.gserviceaccount\\.com$"))
    and (.private_key | startswith("-----BEGIN PRIVATE KEY-----"))
  ' "$file" >/dev/null 2>&1 || continue

  jq -r --arg file "$file" '
    "\($file)\tproject=\(.project_id)\temail=\(.client_email)\tkey_id=\((.private_key_id // "")[0:8])..."
  ' "$file"
done

Do not print .private_key. Do not paste the JSON into chat. File path, project ID, and client email are enough for debugging.

</step>

<step n="3" title="If no JSON exists, create/download one">

Use the official shape: create/select a Google Cloud project, enable the Google Play Android Developer API, create a service account, create a JSON key, then grant the service-account email access in Play Console.

If the user sees a Google Cloud project selector with "Nouveau projet" and no obvious "linked project", that is normal enough. Create or select a dedicated Cloud project for Play publishing. Do not burn time looking for a hidden linked-project list. The real access gate is:

  1. androidpublisher.googleapis.com enabled on the Cloud project.
  2. Service account JSON key downloaded.
  3. Service-account email invited in Play Console -> Users and permissions.

Manual console path:

Google Cloud Console -> IAM & Admin -> Service Accounts
Google Cloud Console -> APIs & Services -> Library -> Google Play Android Developer API -> Enable
Play Console -> Users and permissions -> Invite new user

CLI path when gcloud is already authenticated and the user has chosen {project_id}:

gcloud config set project "{project_id}"
gcloud services enable androidpublisher.googleapis.com
gcloud iam service-accounts create play-publisher --display-name "NowStack Play Publisher"
gcloud iam service-accounts keys create "$HOME/Downloads/nowstack-play-publisher.json" \
  --iam-account "play-publisher@{project_id}.iam.gserviceaccount.com"

The downloaded JSON key is a secret. It can be recreated later by creating another key, but this exact private key is only shown/downloaded at creation time.

</step>

<step n="4" title="Grant Play Console permissions">

Open Play Console as the account owner/admin and invite the service-account email from the JSON:

jq -r .client_email mobile-app/google-play-service-account.json

Grant app-scoped access to the NowStack app/package dev.melvynx.nowstack. Minimum practical permissions depend on the target flow:

Prefer app-scoped permissions over full account admin. Use account-level admin only if the release automation truly needs broad access and the user explicitly accepts it.

</step>

<step n="5" title="Organize the JSON">

Keep the canonical runtime path in the repo-ignored file that existing NowStack skills expect:

mkdir -p "$HOME/Developer/google-play"

# Replace the source path with the verified candidate JSON.
install -m 600 "/path/to/verified-service-account.json" \
  "$HOME/Developer/google-play/nowstack-play-service-account.json"

ln -sf "$HOME/Developer/google-play/nowstack-play-service-account.json" \
  mobile-app/google-play-service-account.json

chmod 600 "$HOME/Developer/google-play/nowstack-play-service-account.json"

If the verified JSON is still in ~/Downloads, move it out of Downloads after setup so future agents do not pick an old duplicate.

</step>

<step n="6" title="Validate locally and with gpc">

First validate the file shape without exposing secrets:

export GPC_APP="dev.melvynx.nowstack"
export GPC_SERVICE_ACCOUNT="$PWD/mobile-app/google-play-service-account.json"

jq -e '
  .type == "service_account"
  and (.client_email | test("@.*\\.iam\\.gserviceaccount\\.com$"))
  and (.private_key | startswith("-----BEGIN PRIVATE KEY-----"))
  and (.project_id | length > 0)
' "$GPC_SERVICE_ACCOUNT" >/dev/null

jq -r '"project=\(.project_id)\nemail=\(.client_email)\nkey_id=\((.private_key_id // "")[0:8])..."' "$GPC_SERVICE_ACCOUNT"

Then authenticate and verify read-only Play access:

gpc auth login --service-account "$GPC_SERVICE_ACCOUNT"
gpc doctor
gpc status

If gpc is unavailable or blocked, validate with Fastlane as a fallback:

bundle exec fastlane run validate_play_store_json_key json_key:"$GPC_SERVICE_ACCOUNT"

After this skill succeeds, Android upload/promotion belongs to ns-deploy-android-app, ns-android-beta, or ns-android-distribute.

</step>

<step n="7" title="Persist non-secret findings">

Record only non-secret operational facts in AGENTS.md, release notes, or agent memory:

Never record the private key, full JSON contents, or any copied secret material.

</step>

<failure_modes>

</failure_modes>

<critical_safety>

</critical_safety>

<references>

</references>

<success_criteria>

</success_criteria>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.