ruby – How to sign in with an Apple ID in PHP, to avoid "Invalid Client" error-ThrowExceptions

Exception or error:

Here are my parameters:

response_type=code%20id_token&client_id=[CLIENT_ID]&redirect_uri=[REDIRECT_URI]&scope=email%20name&response_mode=form_post

The OAuth page says:

'Error getting an access token:' with description: 'Invalid Client'.

My code is:

require 'jwt'

key_file = 'key.p8'
ecdsa_key = OpenSSL::PKey::EC.new IO.read key_file

headers = {
    'kid' => 'key id'
}

claims = {
    'iss' => 'team id',
    'iat' => Time.now.to_i,
    'exp' => Time.now.to_i + (86400*180),
    'aud' => 'https://appleid.apple.com',
    'sub' => 'client_id,
}

token = JWT.encode claims, ecdsa_key, 'ES256', headers

puts token

I wonder if there are parameters in the Ruby file that do not generate the token properly or that do not include this error on another page?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *