class AppleSignIn::RefreshTokenRetriever
Public Instance Methods
call(authorization_data)
click to toggle source
# File lib/apple_sign_in/refresh_token_retriever.rb, line 11 def call(authorization_data) body = build_body(authorization_data) response = apple_api_caller.post("/auth/token", body) parse(response) end
Private Instance Methods
build_body(authorization_data)
click to toggle source
# File lib/apple_sign_in/refresh_token_retriever.rb, line 32 def build_body(authorization_data) { "client_id" => extract_apple_client_id(authorization_data["identity_token"]), "client_secret" => secret(authorization_data["identity_token"]), "grant_type" => "authorization_code", "code" => authorization_data["authorization_code"], "redirect_uri" => apple_redirect_uri } end
extract_apple_client_id(identity_token)
click to toggle source
# File lib/apple_sign_in/refresh_token_retriever.rb, line 42 def extract_apple_client_id(identity_token) token_payload = JSON::JWT.decode(identity_token, :skip_verification) token_payload["aud"] end
handle_error(response)
click to toggle source
# File lib/apple_sign_in/refresh_token_retriever.rb, line 25 def handle_error(response) Rollbar.error(response) return raise(AppleSignIn::Error, response.body.to_s) if response.code == 400 raise(AppleSignIn::Error, response.code.to_s) end
parse(response)
click to toggle source
# File lib/apple_sign_in/refresh_token_retriever.rb, line 19 def parse(response) return JSON.parse(response.body) if response.code == 200 handle_error(response) end
secret(identity_token)
click to toggle source
# File lib/apple_sign_in/refresh_token_retriever.rb, line 47 def secret(identity_token) apple_client_secret_generator.generate(identity_token) end