class AppleID::Client
Public Class Methods
new(attributes)
click to toggle source
Calls superclass method
# File lib/apple_id/client.rb, line 7 def initialize(attributes) attributes_with_default = { authorization_endpoint: File.join(ISSUER, '/auth/authorize'), token_endpoint: File.join(ISSUER, '/auth/token') }.merge(attributes) super attributes_with_default end
Public Instance Methods
access_token!(options = {})
click to toggle source
Calls superclass method
# File lib/apple_id/client.rb, line 15 def access_token!(options = {}) self.secret = client_secret_jwt super :body, options end
Private Instance Methods
client_secret_jwt()
click to toggle source
# File lib/apple_id/client.rb, line 22 def client_secret_jwt jwt = JSON::JWT.new( iss: team_id, aud: ISSUER, sub: identifier, iat: Time.now, exp: 1.minutes.from_now ) jwt.kid = key_id jwt.sign(private_key) end
handle_error_response(response)
click to toggle source
# File lib/apple_id/client.rb, line 46 def handle_error_response(response) error = JSON.parse(response.body).with_indifferent_access raise Error.new(response.status, error) end
handle_success_response(response)
click to toggle source
# File lib/apple_id/client.rb, line 41 def handle_success_response(response) token_hash = JSON.parse(response.body).with_indifferent_access AccessToken.new token_hash.delete(:access_token), token_hash.merge(client: self) end
setup_required_scope(scopes)
click to toggle source
# File lib/apple_id/client.rb, line 34 def setup_required_scope(scopes) # NOTE: # openid_connect gem add `openid` scope automatically. # However, it's not required for Sign-in with Apple. scopes end