nhosoya / omniauth-apple

OmniAuth strategy for Sign In with Apple
MIT License
260 stars 99 forks source link

Stuck on Request Phase Initiated #79

Closed vasaf closed 2 years ago

vasaf commented 2 years ago

In my logs I get stuck on: DEBUG -- omniauth: (apple) Request phase initiated.

Routes:

GET|POST /users/auth/apple(.:format)
GET|POST /users/auth/apple/callback(.:format)

omniauth controller:

def apple
    @user = User.from_omniauth(request.env['omniauth.auth'])
    if @user.persisted?
      sign_in_and_redirect @user, event: :authentication
      set_flash_message(:notice, :success, kind: 'apple') if is_navigational_format?
    else
      session['devise.apple_data'] = request.env['omniauth.auth'].except(:extra)
      redirect_to new_user_registation_url
    end
  end

devise initalizer:

config.omniauth :apple, Rails.application.credentials.apple[:client_id], '',
                  {
                    scope: 'email name',
                    team_id: Rails.application.credentials.apple[:team_id],
                    key_id: Rails.application.credentials.apple[:key_id],
                    pem: OpenSSL::PKey::EC.new(Rails.application.credentials.apple[:secret_key]).to_pem,
                    callback_path: "/users/auth/apple/callback",
                    authorized_client_ids: Rails.application.credentials.apple[:client_id],
                    provider_ignores_state: true
                  }

I had a problem with no curve for nil class which was solved by passing the key as pem properly, but now I can't get past request phase initiated..

vasaf commented 2 years ago

Turns out its a hotwire/turbo issue.

Fixed by changing my link_to to a button_to and added turbo: "false" like so: <%= button_to "Sign in with Apple", user_apple_omniauth_authorize_path, method: :post, data: {turbo: "false"} %>