checkAccess method
Checks that the service account can open an edit for packageName (and
discards it). Throws PlayException with the reason when it cannot.
Implementation
Future<void> checkAccess(String packageName) async {
final keyPath = config.play.serviceAccountJson;
if (keyPath == null && httpClient == null) {
throw PlayException('No Play credentials are configured.');
}
final client = httpClient ??
await clientViaServiceAccount(
ServiceAccountCredentials.fromJson(
File(keyPath!).readAsStringSync()),
[ap.AndroidPublisherApi.androidpublisherScope]);
try {
final api = ap.AndroidPublisherApi(client);
final edit = await api.edits.insert(ap.AppEdit(), packageName);
await _discardEdit(api, packageName, edit.id!);
} on ap.DetailedApiRequestError catch (e) {
throw PlayException('Google Play API error ${e.status}: ${e.message}');
} finally {
if (httpClient == null) client.close();
}
}