As a proof of concept, I am trying to create bare-bones mac-command line app (in Swift) that allows me to send a string as push notification to my own iPhone.
I'm trying to follow the guide from Apple, however, I'm stuck creating the Jason Web Token. The guide kindly refers to JWT documentation, and leaves the most difficult part as an exercise to the user: actually creating the JWT (turning the difficulty up to 11 for me ;) ).
I've tried a number of things (mostly by scraping on the internets, sadly), but when I try to verify my token at the [JWT site](https://jwt. io), is always invalid.
High level, here is my understanding (let's sanity check my thinking, before diving into details:
- Create 3 JSON-strings: header, claims and payload
- Base64 encode each one separately
- Combine these three pieces of data like so
let Data((headerBase64String + "." + claimsBase64String + "." + payloadBase64String).utf8)
- Encrypt this this data using an algorithm called 'ES256' (no idea how to do this, could not find any documentation within Cryptokit on this one).
- Print the data as string, and enter the results into [JWT site](https://jwt. io). No joy.
I would like to use nothing but default libraries (i.e. Foundation, Cryptokit etc), and not make use of IBM's Kibana project (which is what majority of online suggestions seem to be doing). I'm aiming for a thorough understanding here.
Where do I need help to kickstart my understanding?