相关疑难解决方法(0)

无法从Google Play Android Developer API获取订阅信息

我正在使用Google API Client Library for Java来获取有关在我的Android应用程序中购买的用户订阅的信息.这就是我现在正在做的事情:

HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();

GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
                    .setJsonFactory(JSON_FACTORY)
                    .setServiceAccountId(GOOGLE_CLIENT_MAIL)
                    .setServiceAccountScopes("https://www.googleapis.com/auth/androidpublisher")
                    .setServiceAccountPrivateKeyFromP12File(new File(GOOGLE_KEY_FILE_PATH))
                    .build();

Androidpublisher publisher = new Androidpublisher.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).
                    setApplicationName(GOOGLE_PRODUCT_NAME).
                    build();

Androidpublisher.Purchases purchases = publisher.purchases();
Get get = purchases.get("XXXXX", subscriptionId, token);
SubscriptionPurchase subscripcion = get.execute(); //Exception returned here
Run Code Online (Sandbox Code Playgroud)

GOOGLE_CLIENT_MAIL是来自Google控制台的API Access的电子邮件地址. GOOGLE_KEY_FILE_PATH是从API Access下载的p12文件.
GOOGLE_PRODUCT_NAME是品牌信息的产品名称.
在Google APIS控制台中,启用了"Google Play Android Developer API"服务.

我得到的是:

{
  "code" : 401,
  "errors" : [ {
    "domain" : "androidpublisher",
    "message" …
Run Code Online (Sandbox Code Playgroud)

java android google-api subscription google-play

25
推荐指数
3
解决办法
2万
查看次数

使用oAuth和youtube进行身份验证时,总是会遇到错误:第二次尝试时出现invalid_grant,为什么?

截至昨天,我的应用程序能够通过oAuth 2.0与google(youtube)进行身份验证,第一次没问题,但第二次(重新身份验证,相同的应用程序+同一用户),当我为accessToken交换requestToken时,我得到了一个错误:

error : invalid_grant
Run Code Online (Sandbox Code Playgroud)

我正在使用:

grant_type = authorization_code
Run Code Online (Sandbox Code Playgroud)

他们建议的.过去两天前发生的事情是重新验证,网页会说"您之前已使用此应用程序进行过身份验证,是否要再次授予其访问权限?".改变了什么或者我做错了什么?

youtube google-api gdata

10
推荐指数
1
解决办法
1万
查看次数

www.googleapis.com/androidpublisher/v1/上的GET 500内部服务器错误

最后,我可以解决我最近处理用于访问google API的OAuth2身份验证的问题.

但现在我在查询android开发人员API以检索有关订阅的状态信息时遇到困难.我正在使用以下REST API调用:

https://www.googleapis.com/androidpublisher/v1/applications/ APP_PACKAGE/subscriptions/SUBSCRIPTION_ID/purchases/PURCHASE_TOKEN?access_token = AUTH_TOKEN

  • APP_PACKAGE 我上传到开发者控制台的应用程序的包名称
  • SUBSCRIPTION_ID为应用程序指定的订阅ID(开发人员控制台)
  • PURCHASE_TOKEN (虚拟)购买令牌
  • AUTH_TOKEN 从OAuth2检索的身份验证令牌.

我检索此请求的身份验证令牌如下:

// Build the HTTP parameter
Map<String,String> params = [:]
params.put("grant_type", "refresh_token")
params.put("refresh_token", googleRefreshToken.encodeAsURL())
params.put("client_id", googleClientId.encodeAsURL())
params.put("client_secret", googleClientSecret.encodeAsURL())

// Send the POST request
// This action might throw an exception in case any parameter were wrong, invalid or not specified.
String result = HttpRequestHandler.sendRequest("https://accounts.google.com/o/oauth2/token", params);
JSONElement jsonResult = JSON.parse(result)
Run Code Online (Sandbox Code Playgroud)

这工作得很好,但上面提到的REST调用返回500错误 - …

api android subscription

5
推荐指数
0
解决办法
2067
查看次数

标签 统计

android ×2

google-api ×2

subscription ×2

api ×1

gdata ×1

google-play ×1

java ×1

youtube ×1