Class: OmniAuth::Strategies::KakaoOauth2

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/kakao_oauth2.rb

Overview

OmniAuth OAuth2 strategy for Kakao authentication This strategy properly handles client_secret in the request body as required by Kakao's API

Instance Method Summary collapse

Instance Method Details

#build_access_tokenObject

Override to include client_secret in request body instead of header



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/omniauth/strategies/kakao_oauth2.rb', line 43

def build_access_token
  verifier = request.params["code"]
  
  # Build token parameters with optional client_secret in the body
  token_params = {
    redirect_uri: callback_url,
    client_id: options.client_id,
    grant_type: "authorization_code"
  }
  
  # Include client_secret only if provided (optional parameter)
  token_params[:client_secret] = options.client_secret if options.client_secret
  
  # Merge any additional token parameters
  token_params.merge!(options.token_params || {})

  client.auth_code.get_token(verifier, token_params, deep_symbolize(options.auth_token_params || {}))
end