This repository is a sample Rails application utilizing Devise, OmniAuth, and OmniAuth::Apple. The application is built with Ruby 3.2.2 and Rails 7.1.3.2.
Add the following gems to your Gemfile:
gem 'devise'
gem 'dotenv-rails'
gem 'omniauth'
gem 'omniauth-rails_csrf_protection'
gem 'omniauth-apple'
Then, run bundle install to install the gems.
bundle exec rails g devise:install
bundle exec rails g devise user
bundle exec rails g migration add_columns_to_users provider uid username
bundle exec rake db:migrate
Set up the following environment variables in your .env file:
- APPLE_CLIENT_ID=
- APPLE_TEAM_ID=
- APPLE_KEY_ID=
- APPLE_PRIVATE_KEY=
- config/application.rb
- config/routes.rb
- config/environments/development.rb
- config/initializers/devise.rb
- config/initializers/omniauth.rb
- config/initializers/omniauth.rb
- app/controllers/users/omniauth_callbacks_controller.rb
- app/models/user.rb
- Can't verify CSRF token authenticity when returning from auth · Issue #54 · nhosoya/omniauth-apple
- skip_before_action :verify_authenticity_token
- skip_before_action :verify_authenticity_token
HTTP Origin header (https://appleid.apple.com) didn't match request.base_url
config.hosts.clear
Special thanks to all contributors and the open-source community for their valuable resources and support.