Sha256: f316379e79af9cccda587ba536569835f2b801d1ef3101832a19be88c82997f0
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 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: ENV.fetch("APPLE_BUNDLE_ID"), client_secret: ENV.fetch("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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shimmer-0.0.13 | lib/shimmer/auth/apple_provider.rb |