我正在尝试使用Java的Google API客户端库来获取有关在我的Android应用中购买的用户订阅的信息。然后我得到了这个错误:
{
"code" : 401,
"errors" : [ {
"domain" : "androidpublisher",
"message" : "The current user has insufficient permissions to perform the requested operation.",
"reason" : "permissionDenied"
} ],
"message" : "The current user has insufficient permissions to perform the requested operation."
}
我正在尝试这些步骤:
我正在尝试此代码:
httpTransport = new com.google.api.client.http.javanet.NetHttpTransport();
JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();
String applicationName = "App name";
String packageName = "com.example.xxx";
final Set<String> scopes = Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER);
AssetManager am = getAssets();
InputStream inputStream = am.open("key1.p12");
File file = createFileFromInputStream(inputStream);
Log.d(TAG, "file : " + file);
if(file != null){
int SDK_INT = android.os.Build.VERSION.SDK_INT;
if (SDK_INT > 8) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId("pp-subscription@practice-presto-dev.iam.gserviceaccount.com").setServiceAccountScopes(scopes)
//.setServiceAccountId("practice-presto-subscription@practice-presto-dev.iam.gserviceaccount.com").setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(file).build();
AndroidPublisher pub = new AndroidPublisher.Builder
(httpTransport, jsonFactory, credential)
.setApplicationName(applicationName)
.build();
final AndroidPublisher.Purchases.Subscriptions.Get get =
pub.purchases().subscriptions().get(packageName, "sub_monthly_pro", "pcehicpbjhcdnjockiniaokh.AO-J1OxsJtLehF3z_naoXR4LE0jqiXrABAPYiZMNRMZO5jnKI9gnyHmPP7INtcc2kyptNKP_HM6MjEPQfmYWmJ8R_geonsLqMXA9TLsozqNexh-FxSvQFDZSUTgBW_azvdAJPLxPFuKd");
final SubscriptionPurchase purchase = get.execute();
Log.d(TAG, "Found google purchase item " + purchase.toPrettyString());
}
}
我正在测试应用内购买模式。
我想在续订订阅计划后获取最新的订阅收据。
答案 0 :(得分:0)
24小时后,我检查了错误。但是之后,两天后我再次检查没有错误,并且已经接收到数据。