由于Google现在需要一种取消应用中订阅的方法,我们不得不为我们的颤振应用程序添加一个REST调用(使用来自这里的端点),因为颤动. 不支持这一点
然而,当我们打电话时,我们得到了一个带有{“code”: 7225, “message”:”Invalid API Key”}
. 响应的401
static Future<bool> cancelSubscription(Package package) async {
try {
var options = Options(headers: {
'Accept': 'application/json',
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
});
var response = await Dio().post('https://api.revenuecat.com/v1/subscribers/$appUserId/subscriptions/${package.product.identifier}/revoke', options: options);
return response.statusCode != null && response.statusCode == 200;
}
catch (ex) {
if (kDebugMode) print(ex);
}
return false;
}
我也可以在cURL中轻松地重新创建。
curl --request POST --url https://api.revenuecat.com/v1/subscribers/zzzzzzzzzzzzzzzzzzz/subscriptions/chip_subscription_1m/revoke --header "Accept: application/json" --header "Authorization: Bearer goog_Oxxxxxxxxxxxxxxxxxxxxxxxxxx" --header "Content-Type: application/json"
在标头中发送的键与颤振库初始化时使用的键相同:
static Future<void> init(String playerId) async {
apiKey = Platform.isAndroid
? dotenv.get('revenuecat_api_android')
: dotenv.get('revenuecat_api_ios');
appUserId = playerId;
await Purchases.setDebugLogsEnabled(kDebugMode);
await Purchases.setup(apiKey, appUserId: playerId);
}
因为它适用于库,所以我希望它可以用于REST接口。它需要编码还是什么奇怪的地方?
发布于 2022-08-05 03:09:52
明白了- RevenueCat有两种API键。有特定于应用程序的API密钥和秘密API密钥(用于“访问附加API函数”),只需创建其中一个(并将其添加到密钥存储库)。不确定为什么他们选择让您使用一个API键创建,而必须用另一个API键取消。。。
https://stackoverflow.com/questions/73243646
复制