Post

Replies

Boosts

Views

Activity

Reply to JWT authentication with App Store server always 401
I am still not able to create a valid token using everything right still not able to figure out wats wrong!! const OpenSSL = require('openssl-nodejs') const fs = require('fs'); const path = require('path'); var jwt = require('jsonwebtoken'); var http = require('http') function getToken() { const now = Math.round(new Date().getTime() / 1000); const expirationTime = now + 1999; const privateKey = fs.readFileSync('./AuthKey_W467528DJL.p8') const headers = { algorithm: 'ES256', header: { alg: 'ES256', kid: 'W467528DJL', typ: 'JWT', }, }; let payload = { iss: '8b3af5d2-f293-452c-8df1-6d023149279b', exp: expirationTime, aud: 'appstoreconnect-v1', bid: 'org.momly.app' } const token = jwt.sign(payload, privateKey, { algorithm: 'ES256', header: { alg: 'ES256', kid: 'W467528DJL', typ: 'JWT', } }); console.log("token ---> " + token); const verify = jwt.verify(token, privateKey) console.log("Verify", verify) }; getToken() please provide help to how to get a valid token
Dec ’22
Reply to App store connect API returns 401 with production url but works with sandbox url
Hi, i am still not able to get the response successully here is my code in node js const now = Math.round(new Date().getTime() / 1000); const expirationTime = now + 1999; const privateKey = fs.readFileSync('./AuthKey_W467528DJL.p8') const headers = { algorithm: "ES256", header: { alg: "ES256", kid: "W467528DJL", typ: "JWT", }, }; let payload = { "iss": "8b3af5d2-f293-452c-8df1-6d023149279b", "iat": now, "exp": expirationTime, "aud": "appstoreconnect-v1", "bid": "org.momly.app" } const token = jwt.sign(payload, privateKey, headers); const callHeaders = { "Accept": "application/a-gzip; application/json", "Authorization": "Bearer " + token, } axios.get('https://api.appstoreconnect.apple.com/v1/apps', { headers: callHeaders }).then((response) => { console.log("Response", response.toJSON()) }).catch((error) => { console.log("error", error.message) }) }; Please let me know what is the exact issue. i have tried everything thats there over the internet
Dec ’22