Authentication
GPC supports four authentication methods. Service accounts are recommended for CI/CD; OAuth is available for interactive use.
| Method | Best For | Requires | Interactive |
|---|---|---|---|
| Service account | CI/CD, automation | JSON key file | No |
| OAuth 2.0 | Developer machines | Google account | Yes |
| Environment variable | CI/CD secrets | GPC_SERVICE_ACCOUNT | No |
| Application Default Credentials | GCP-hosted workloads | gcloud or metadata server | No |
Google Cloud Setup
All authentication methods require a Google Cloud project with the Google Play Developer API enabled and appropriate Play Console access.
Step 1: Create a Google Cloud Project
Go to the Google Cloud Console and create a new project (or use an existing one).
Project name: my-play-deploy
Project ID: my-play-deploy-123456Step 2: Enable the Google Play Developer API
gcloud services enable androidpublisher.googleapis.com --project my-play-deploy-123456Or enable it in the API Library.
Step 3: Create a Service Account
gcloud iam service-accounts create play-deploy \
--display-name "Play Store Deploy" \
--project my-play-deploy-123456Step 4: Download the JSON Key File
gcloud iam service-accounts keys create service-account-key.json \
--iam-account play-deploy@my-play-deploy-123456.iam.gserviceaccount.comThis creates a service-account-key.json file in your current directory. Store this securely -- it grants access to your Play Console account.
Step 5: Invite the Service Account in Play Console
- Go to Google Play Console > Users and permissions
- Click Invite new users
- Enter the service account email:
play-deploy@my-play-deploy-123456.iam.gserviceaccount.com - Set the permissions listed in the Permissions section below
- Add specific app access or grant account-level access
- Click Invite user and then Send invite
The service account is active immediately after invitation. No acceptance step is required.
Required API Scopes
GPC requests two OAuth scopes:
https://www.googleapis.com/auth/androidpublisher
https://www.googleapis.com/auth/playdeveloperreportingThe androidpublisher scope covers the Publisher API (app management, releases, listings, monetization). The playdeveloperreporting scope is required for the Reporting API (vitals, crash rates, error issues, anomalies).
Enable the Reporting API
If you use gpc vitals commands, ensure the Google Play Developer Reporting API is enabled in your Google Cloud project:
gcloud services enable playdeveloperreporting.googleapis.com --project my-play-deploy-123456Service Account
The recommended method for CI/CD pipelines and automated workflows.
Login with a key file
gpc auth login --service-account /path/to/service-account-key.jsonExpected output:
Authenticated as play-deploy@my-play-deploy-123456.iam.gserviceaccount.com
Profile "default" savedThe credentials are saved to your profile. Subsequent commands use the cached credentials automatically.
Login with a named profile
gpc auth login --service-account /path/to/production-key.json --profile productiongpc auth login --service-account /path/to/staging-key.json --profile stagingSwitch between profiles:
gpc auth switch productionToken lifecycle
When using a service account, GPC:
- Reads the private key from the JSON key file
- Signs a JWT with the
androidpublisherscope - Exchanges the JWT for an access token (valid for 1 hour)
- Caches the access token in memory and on disk
- Automatically refreshes the token when it expires (within 5 minutes of expiry)
Performance optimizations:
- In-memory cache -- subsequent requests skip filesystem I/O entirely
- Mutex deduplication -- concurrent requests share a single token refresh instead of racing to sign multiple JWTs
- Smart 401 refresh -- tokens are only re-fetched on authentication failures, not on rate limit or server errors
Tokens are never written to logs or command output. The --verbose flag shows token exchange timing but redacts the token value.
OAuth 2.0
For interactive use on developer machines. Opens a browser for Google account authentication.
gpc auth loginExpected output:
Opening browser for authentication...
If the browser does not open, visit this URL:
https://accounts.google.com/o/oauth2/v2/auth?client_id=...&scope=...
Waiting for authorization...
Authenticated as developer@example.com
Profile "default" savedOAuth tokens are cached in the profile. The refresh token is used to obtain new access tokens without re-authenticating.
Token lifecycle
When using OAuth:
- GPC opens a browser for Google account authorization
- The user grants the
androidpublisherscope - GPC receives an authorization code via local redirect
- The code is exchanged for an access token (1 hour) and refresh token (long-lived)
- Both tokens are cached in the profile
- When the access token expires, GPC uses the refresh token to get a new one automatically
Revoking OAuth tokens
gpc auth logoutThis revokes the refresh token with Google and deletes the cached credentials from the profile.
Environment Variable
Set the GPC_SERVICE_ACCOUNT environment variable to either a file path or a JSON string. This method is ideal for CI/CD where secrets are injected as environment variables.
File path
export GPC_SERVICE_ACCOUNT=/path/to/service-account-key.json
gpc apps listJSON string
export GPC_SERVICE_ACCOUNT='{"type":"service_account","project_id":"my-project","private_key_id":"abc123","private_key":"-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n","client_email":"play-deploy@my-project.iam.gserviceaccount.com","client_id":"123456789","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token"}'
gpc apps listGitHub Actions example
env:
GPC_SERVICE_ACCOUNT: ${{ secrets.GPC_SERVICE_ACCOUNT_JSON }}
steps:
- name: List apps
run: gpc apps listGitLab CI example
variables:
GPC_SERVICE_ACCOUNT: $GPC_SERVICE_ACCOUNT_JSON
deploy:
script:
- gpc apps listWhen GPC_SERVICE_ACCOUNT is set, it takes precedence over profile-based credentials. No gpc auth login step is needed.
Application Default Credentials
ADC uses the credentials from gcloud auth application-default login or from GCP metadata servers (when running on Google Cloud infrastructure).
Local development
gcloud auth application-default login --scopes=https://www.googleapis.com/auth/androidpublisher
gpc apps listGCP workloads
On Compute Engine, Cloud Run, Cloud Functions, or GKE, ADC uses the instance's service account automatically. No configuration is needed if the instance's service account has the androidpublisher scope.
Precedence
ADC is the lowest-priority auth method. GPC checks for credentials in this order:
--service-accountCLI flagGPC_SERVICE_ACCOUNTenvironment variable- Profile-based credentials (from
gpc auth login) - Application Default Credentials
Play Console Permissions
The service account (or user) must have appropriate permissions in Google Play Console. Permissions are set per-app or at the account level.
Account-level permissions
| Permission | Required For | GPC Commands |
|---|---|---|
| View app information and download bulk reports | Read access to all apps | apps list, apps info, reports download |
| View financial data, orders, and cancellation survey responses | Financial reports, purchases | reports download financial, purchases get, orders refund |
| Manage orders and subscriptions | Purchase management | purchases acknowledge, purchases consume, purchases subscription cancel |
App-level permissions
| Permission | Required For | GPC Commands |
|---|---|---|
| View app information | Read metadata and stats | apps info, vitals overview, reviews list |
| Create, edit, and delete draft apps | App creation | (future: apps create) |
| Release to production, exclude devices, and use Play App Signing | Production releases | releases upload --track production, releases promote --to production |
| Release apps to testing tracks | Internal/alpha/beta releases | releases upload --track internal, releases promote --to beta |
| Manage testing tracks and edit tester lists | Tester management | testers list, testers add, testers remove |
| Manage store presence | Listings and metadata | listings update, listings push, listings images upload |
| Reply to reviews | Review replies | reviews reply |
| Manage policy compliance submissions | (future) | N/A |
Recommended CI/CD permissions
For a CI/CD service account that uploads and promotes releases, set these app-level permissions:
- View app information
- Release apps to testing tracks
- Release to production, exclude devices, and use Play App Signing
- Manage store presence (if updating listings)
- Manage testing tracks and edit tester lists (if managing testers)
Profile Management
GPC supports multiple named profiles for switching between accounts or environments.
List profiles
gpc auth profilesExpected output:
Profiles:
* default play-deploy@my-project.iam.gserviceaccount.com (active)
staging staging-deploy@my-project.iam.gserviceaccount.com
production prod-deploy@my-project.iam.gserviceaccount.comSwitch active profile
gpc auth switch productionExpected output:
Switched to profile "production"
Active identity: prod-deploy@my-project.iam.gserviceaccount.comUse a profile for a single command
gpc apps list --profile stagingThe --profile flag overrides the active profile for that command only.
Show current identity
gpc auth whoamiExpected output:
play-deploy@my-project.iam.gserviceaccount.com (service-account, profile: default)Check auth status
gpc auth statusExpected output:
Profile: default
Identity: play-deploy@my-project.iam.gserviceaccount.com
Method: service-account
Token: valid (expires in 58 minutes)
Scopes: https://www.googleapis.com/auth/androidpublisherRemove a profile
gpc auth logout --profile stagingThis removes the cached credentials for the specified profile. If no --profile flag is given, the active profile is logged out.
Troubleshooting
"Permission denied" errors
The service account email must be invited in Play Console with the correct permissions. Check:
gpc auth whoamiVerify the email matches the one invited in Play Console > Users and permissions.
"Token expired" errors
GPC refreshes tokens automatically. If you see token errors, check your system clock:
date -uThe system clock must be within 5 minutes of UTC. NTP sync issues are the most common cause of token errors in CI/CD.
"API not enabled" errors
Ensure the Google Play Developer API is enabled in your Google Cloud project:
gcloud services list --enabled --project my-play-deploy-123456 | grep androidpublisherExpected output:
androidpublisher.googleapis.com Google Play Android Developer APIRun the doctor command
gpc doctorThis verifies authentication, API connectivity, and configuration in one step.
Next Steps
- Configuration -- Config files, environment variables, and profiles
- Quick Start -- Run your first commands
- CI/CD Integration -- GitHub Actions, GitLab CI, and more