Open AbhayPai opened 2 years ago
`require 'jwt' require 'openssl'
team_id = ' ' #app id key_id = ' ' #keys apple client_id = ' ' #bundleid
auth_key = OpenSSL::PKey::EC.new(File.read('AuthKey_XA4T9N4ZK5.p8'))
header = { 'kid': key_id, }
palyload = { 'iss' => team_id, 'iat' => Time.now.to_i, 'exp' => Time.now.to_i + 86400 * 180, # 180 days from now 'aud' => 'client_id write', 'sub' => client_id } token = JWT.encode(palyload, auth_key,'ES256', header)
puts token`
This code will do the job. If you run it with Ruby, you will get the secret key.
I have all the values which are required, only thing i want as encryption in server level is to generate client_secret value from p8 key value itself. Ex:- from
JWKFactory::createFromKeyFile($keyfile)
to something likeJWKFactory::createFromKey('passing-key-value')
Will this work ?