401 unautheticate error for iap sandbox/production server notification

We followed same step as given documentation but when we request for sever notification we are getting 401 unautheticate error

below is my request

curl -v -H 'Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjNCQzczUjlEV0MifQ.eyJpc3MiOiI2OWE2ZGU4ZS1iNGZhLTQ3ZTMtZTA1My01YjhjN2MxMWE0ZDEiLCJhdWQiOiJhcHBzdG9yZWNvbm5lY3QtdjEiLCJpYXQiOjE2ODc3NzQzNzI1MDEsImV4cCI6MTY4Nzc3Nzk3MjUwMSwiYmlkIjoiY29tLm9uZmVyZW5jZS5vbmZlcmVuY2VhcHAifQ.IA0eQHGgW4MTmXPm7qWQDsav-9e5KSR8N_64ge3DSo_E39wxFUcs3JnJUgtq-uOJ1nr49FiUrFPyZGTQpdQOBg' "https://api.storekit-sandbox.itunes.apple.com/inApps/v1/notifications/test"

  • Trying 17.36.202.8...
  • TCP_NODELAY set
  • Connected to api.storekit-sandbox.itunes.apple.com (17.36.202.8) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/cert.pem

CApath: none

  • TLSv1.2 (OUT), TLS handshake, Client hello (1):
  • TLSv1.2 (IN), TLS handshake, Server hello (2):
  • TLSv1.2 (IN), TLS handshake, Certificate (11):
  • TLSv1.2 (IN), TLS handshake, Server key exchange (12):
  • TLSv1.2 (IN), TLS handshake, Server finished (14):
  • TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
  • TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
  • TLSv1.2 (OUT), TLS handshake, Finished (20):
  • TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
  • TLSv1.2 (IN), TLS handshake, Finished (20):
  • SSL connection using TLSv1.2 / ECDHE-RSA-CHACHA20-POLY1305
  • ALPN, server accepted to use h2
  • Server certificate:
  • subject: businessCategory=Private Organization; jurisdictionCountryName=US; jurisdictionStateOrProvinceName=California; serialNumber=C0806592; C=US; ST=California; L=Cupertino; O=Apple Inc.; CN=commercegateway.itunes.apple.com
  • start date: May 16 16:44:52 2023 GMT
  • expire date: Nov 12 16:54:52 2023 GMT
  • subjectAltName: host "api.storekit-sandbox.itunes.apple.com" matched cert's "api.storekit-sandbox.itunes.apple.com"
  • issuer: C=US; O=Apple Inc.; CN=Apple Public EV Server RSA CA 2 - G1
  • SSL certificate verify ok.
  • Using HTTP2, server supports multi-use
  • Connection state changed (HTTP/2 confirmed)
  • Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
  • Using Stream ID: 1 (easy handle 0x7fbcda00a000)

GET /inApps/v1/notifications/test HTTP/2 Host: api.storekit-sandbox.itunes.apple.com User-Agent: curl/7.64.1 Accept: / Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjNCQzczUjlEV0MifQ.eyJpc3MiOiI2OWE2ZGU4ZS1iNGZhLTQ3ZTMtZTA1My01YjhjN2MxMWE0ZDEiLCJhdWQiOiJhcHBzdG9yZWNvbm5lY3QtdjEiLCJpYXQiOjE2ODc3NzQzNzI1MDEsImV4cCI6MTY4Nzc3Nzk3MjUwMSwiYmlkIjoiY29tLm9uZmVyZW5jZS5vbmZlcmVuY2VhcHAifQ.IA0eQHGgW4MTmXPm7qWQDsav-9e5KSR8N_64ge3DSo_E39wxFUcs3JnJUgtq-uOJ1nr49FiUrFPyZGTQpdQOBg

  • Connection state changed (MAX_CONCURRENT_STREAMS == 1024)!

< HTTP/2 401 < server: daiquiri/3.0.0 < date: Mon, 26 Jun 2023 10:13:59 GMT < content-type: text/plain < strict-transport-security: max-age=31536000; includeSubDomains < x-apple-jingle-correlation-key: 4VK4BGGFURNOK3JZ4FPKMH6ZPA < x-daiquiri-instance: daiquiri:45824002:st44p00it-hyhk15104701:7987:23RELEASE91:daiquiri-amp-commerce-clients-ext-001-st < Unauthenticated

Request ID: 4VK4BGGFURNOK3JZ4FPKMH6ZPA.0.0

  • Connection #0 to host api.storekit-sandbox.itunes.apple.com left intact
  • Closing connection 0

Please help me on this

Replies

In general we recommend using the App Store Server Library to call the App Store Server API, which can remove common issues like setting your validity time longer than 60 minutes.