Authenticating to Apple’s App Store Connect API from Node.js using JWT

Félix Paradis
1 min readFeb 27, 2019

--

I had to connect to Apple’s new App Store Connect API at work and found exactly 0 tutorial and/or code example on how to achieve this from Node.js, which I use. (I did find a good one for Ruby, though, if that’s your thing.)

It’s not very complex, but if you’ve never used JSON Web Tokens before, you might fall in a dumb gotcha like I did. Also, once you do get to generate tokens, if something is wrong with them you will get “401 NOT_AUTHORIZED” as your only clue. So, here I am, saving you some time.

I’m using the jsonwebtoken npm package, but you could use an alternative.

Without further ado, the snippet you need to get going quickly.

Of course, you’ll want to use something else than curl once you authenticate successfully. You’ll probably want to avoid hosting your secret key (the .p8 file) on your server nor commit it as well, but those are considerations for when you can use the API!

Hope this was helpful, cheers !🍻

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Félix Paradis
Félix Paradis

Written by Félix Paradis

Web Developer writing about the web, mostly. Find my other stuff over at www.felixparadis.com

Responses (4)

Write a response