For folks still struggling with this: I had to wait 48h after creating my first key for it to be picked up by Apple servers. For the last two days I've been trying every single solution I could find on-line, thinking that I made a mistake somewhere. Nope.. what fixed it was time (or somebody at apple modifying something on their end). I invoked exactly the same curl request 10 minutes ago and now, getting two different responses from apple's api. EXACTLY the same request (including all parameters).
10 minutes ago: {"error":"invalid_client"}
1 minute ago: {"error":"invalid_grant"} (yes!!!)
now: success (after updating "code" to a fresh authorizationCode generated by my iOS app)
Just be patient. Wait for 48h after creating your first key at https://developer.apple.com/account/resources/authkeys/list