In the link below is explained how to generate JWT token with header and payload to access the Apple API However I don't see how to combine header and payload. Can someone make an example in ruby
https://developer.apple.com/documentation/appstoreserverapi/generating_tokens_for_api_requests
CodePudding user response:
Just use the jwt gem. It's a well-maintained library with regular updates. It's probably possible to do it without a gem too, but anything having to do with security should be air-tight in production, so I would just go with the gem.
Look for the correct encryption algorithm (Apple seems to be using ES256) and find it in the documentation to see an example of how to create a token with that.
The format for creating a basic JWT token with the gem (custom header fields are optional) is this:
JWT.encode your_payload, your_private_key, encryption_algorithm, custom_header_fields