ios – Tips on how to validate a in-app buy within the App Retailer utilizing App Retailer Server API and Node.js (Server-Facet)


Since this technique is deprecated,

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": ""

    const token = jwt.signal(paylaod, keyFileApple, signOptions);

    axios.get('', {
        headers: {
            Authorization: `Bearer ${token}`
        .then(response => {
console.log(response.knowledge, 'good');
        .catch(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 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 (