gpt4 book ai didi

android - 来自 Purchases.Subscriptions.Get 的响应有 EmailAddress、FamilyName 和 GivenName 字段返回 null

转载 作者:行者123 更新时间:2023-12-05 00:05:44 25 4
gpt4 key购买 nike

Google Play 中的 Android 应用 Akita Security https://play.google.com/store/apps/details?id=com.highiot.mob

应用程序有订阅购买。用户从他的设备购买后,我看到他购买的购买 token 并调用 publisherService.Purchases.Subscriptions.Get查看购买我的订阅的用户的姓名和电子邮件。我的问题是在对 Get 的响应中返回的 EmailAddress、GivenName 和 FamilyName 字段为空。价格、国家等其他字段都可以。

我的应用中的购买代码:

 private async void Purcase(string productId)
{
try
{
var connected = await CrossInAppBilling.Current.ConnectAsync();

if (!connected)
{
//Couldn't connect to billing, could be offline, alert user
return;
}

//try to purchase item
CrossInAppBilling.Current.InTestingMode = true;
var purchase = await CrossInAppBilling.Current.PurchaseAsync(productId, ItemType.Subscription, "apppayload");
if (purchase == null)
{
//Not purchased, alert the user
}
else
{
//Purchased, save this information
var id = purchase.Id;
var token = purchase.PurchaseToken;
var state = purchase.State;
bool status = false;
if (state == PurchaseState.PaymentPending)
{
status = true;
}
ViewModel.SendSubscription(productId, token, "Google", status);
}
}
catch (Exception ex)
{
//Something bad has occurred, alert user
}
finally
{
//Disconnect, it is okay if we never connected
await CrossInAppBilling.Current.DisconnectAsync();
}
}

调用 Google API 订阅时的代码。获取:

    static async Task Main(string[] args)
{
bool acknowledge = false;
string projectId = "robotic-circle-243009";
string subscriptionId = "highiot-admin-api";
var _credentialsJson = "HighIoT_key.json";

Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _credentialsJson));

SubscriptionName subscriptionName = new SubscriptionName(projectId, subscriptionId);
SubscriberClient subscriber = await SubscriberClient.CreateAsync(subscriptionName);

GoogleCredential credentialsPlay;
using (var key = new FileStream(_credentialsJson, FileMode.Open, FileAccess.Read))
credentialsPlay = GoogleCredential.FromStream(key).CreateScoped(Scope.Androidpublisher);

var publisherService = new AndroidPublisherService(new BaseClientService.Initializer
{
HttpClientInitializer = credentialsPlay
});

var request1 = publisherService.Purchases.Subscriptions.Get("com.highiot.mob", "com.highiot.mob.test_subsription", "nceeeoihojjngafdmfmahbii.AO-J1Ow8yISTj4C6MW4mKgXYp9Tizo7iZ8JP6PgIRenFLHj4xHaAuCxffDL5jaxEzq_t2IopZXXa4_uLyZYBsXMwk_wn3pwMXoL9rNDWJoZV8SCkVsXcAlaMJe0l2Mn_-OhhuHbjPVP8Tn0ruP4WUlxGPyxUjkNv_Q");
var response1 = request1.Execute();
}

我在 response1 中得到的响应:

Name                     Value

◢ response1 {Google.Apis.AndroidPublisher.v3.Data.SubscriptionPurchase}

AcknowledgementState       1

AutoRenewing false

AutoResumeTimeMillis null

CancelReason 0

▶ CancelSurveyResult {Google.Apis.AndroidPublisher.v3.Data.SubscriptionCancelSurveyResult}

CountryCode “UA”

DeveloperPayload “apppayload”

ETag “\”kLoaNGFQwzHXpxRSLTfX9req9yE/1xXhq0Lm_lUloQUDN3UhbVIoE08\””

EmailAddress null

ExpiryTimeMillis 1568883651389

FamilyName null

GivenName null

Kind “androidpublisher#subscriptionPurchase”

LinkedPurchaseToken null

OrderId “GPA.3309-8881-6545-64850”

PaymentState 1

PriceAmountMicros 21990000

PriceChange null

PriceCurrencyCode “UAH”

ProfileId null

ProfileName null

PurchaseType null

StartTimeMillis 1566205275451

UserCancellationTimeMillis 1566209506502

凭证文件 HighIoT_key.json: { "type": "service_account",

  "project_id": "robotic-circle-243009",


"private_key_id": "cb017791695e97d8b2ab68ae94d940ba07def824",

"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDPJxCrGu1o1AdD\neiBtuxPS/0wdF4chN5KqK0hR8E6x7qfd30I9zI5k07msD3qEo2iuBWwohIeUCWLh\n5x0Xkkx8ADQqWh9Z0HlWcx8JEFIqeKGy+l7j8mnLtv71xxnUSZd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TBu8pK16ZFSXEalvOsFVWSh8KxeaPUgYP3AoGAT0oe\nspSlWhCvYRR4ebh3ZsiYH5Q5fhmnfwCUsKvzrHo1ChYUMLuKb0URafl0dy56fbiP\ncfYjeJJpr77jZYpHR/izjBgzwnSpEweoa0+W8NgDLLrLrqPliLyTPA2xvaMrxZFl\nIBXaZtsMtpW6uFx9N5bFemljkvjFYzfg/lvVtgsCgYEAqMQ8CEjizn91k8ACK6Fs\nFQkCLjSl5h/lvES0+VZDlWMIwos0e6a7vsTVg0IoJ32hY2a7E6R37MbHP2o6lJiS\njJPzBd5pa803DYl8ehId0/8PAUsMscK6LKPblQW9QzoYk5yEjhU1bFLJQfLmmQsV\neRHZgYsNE/U60DnuZsv4wZg=\n-----END PRIVATE KEY-----\n",

"client_email": "highiot-server@robotic-circle-243009.iam.gserviceaccount.com",

"client_id": "110565816019675715733",

"auth_uri": "https://accounts.google.com/o/oauth2/auth",

"token_uri": "https://oauth2.googleapis.com/token",

"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",

"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/highiot-server%40robotic-circle-243009.iam.gserviceaccount.com"

在 Google Play 管理中心: I link the project to the google play console

I add the Service account to the google play console

It's present in the user menu of google play console

在 GOOGLE API 开发者控制台上

I give him permission

In google developer console I gave permission to the service account

And of course I've enabled the google Play Android Developer Api

And added scope to see user info

最佳答案

对于混淆表示歉意,但您提到的字段仅适用于用户 Subscribe with Google .有关这些字段及其可用条件的详尽列表,请参阅 https://developers.google.com/android-publisher/api-ref/purchases/subscriptions

关于android - 来自 Purchases.Subscriptions.Get 的响应有 EmailAddress、FamilyName 和 GivenName 字段返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57557442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com