Since this technique is deprecated https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/validating_receipts_with_the_app_store,
I am making an attempt to arrange validation of purchases on the node utilizing App Retailer Server API
However now I am unable to log in with a token, I get a 401 error
I’ve subsequent code
export const getInfo = async (req, res, subsequent) => {
let now = Math.spherical((new Date()).getTime() / 1000)
let nowPlus20 = now + 1999
const keyFileApple = fs.readFileSync('./keys/apple_purchase_key.p8')
const paylaod = {
"iss": "60a6de96-146c-47e3-e053-5b8c7c11a4d0",
"exp": nowPlus20,
"aud": "appstoreconnect-v1",
}
const signOptions = {
algorithm: "ES256",
header: {
"algorithm": "ES256",
"child": "QNP0H96C0Z",
"typ": "JWT",
"bid": "io.identify.sport"
}
}
const token = jwt.signal(paylaod, keyFileApple, signOptions);
axios.get('https://api.storekit-sandbox.itunes.apple.com/inApps/v1/transactions/consumption/2000000408842280', {
headers: {
Authorization: `Bearer ${token}`
}
})
.then(response => {
console.log(response.knowledge, 'good');
})
.catch(error => {
console.error(error);
});
}
I’ve created the next keys within the developer account:
keyFile in Primary => Keys => In-App Buy => Obtain
KEY ID (child) I took from keyFile
Issuer ID (iss) I took on the highest In-App Buy web page
enter picture description right here
I generate a token, however it’s not appropriate, for instance, for the https://api.storekit-sandbox.itunes.apple.com/inApps/v1/historical past/{transactionId} request
I’ve Error: The request is unauthorized; the JSON Net Token (JWT) is invalid.
Please inform me what the issue is likely to be, possibly I am not creating the keys there?
Or possibly somebody has a superb information or code on how you can do it appropriately?
I am making an attempt to log in to App Retailer Server API to validate my purchases, however I maintain getting a 401 error and I do not perceive why (