Sha256: d61aadbda8e2d302c7fc2c87747abfabfcd825022b4ed85796e7d42699c62340
Contents?: true
Size: 1.01 KB
Versions: 15
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Shimmer module Auth class AppleProvider < Provider self.token_column = :apple_id private def request_details(params) name = params[:user] ? JSON.parse(params[:user])["name"] : {} headers = { 'Content-Type': "application/x-www-form-urlencoded" } form = { grant_type: "authorization_code", code: params[:code], client_id: Config.instance.apple_bundle_id!, client_secret: Config.instance.apple_client_secret, scope: "name email" } response = HTTParty.post("https://appleid.apple.com/auth/token", body: URI.encode_www_form(form), headers: headers) raise InvalidTokenError, "Login check failed: #{response.body}" unless response.ok? token = JWT.decode(response["id_token"], nil, false).first UserDetails.new token: token["sub"], email: token["email"], first_name: name["firstName"], last_name: name["lastName"] end end end end
Version data entries
15 entries across 15 versions & 1 rubygems