#1057·omniauth

request.env['omniauth.auth'] is nil in Omniauth Callback

Author: alec-c4Created Feb 19, 2022Updated Feb 6, 2023

Configuration

  • Provider Gem: omniauth-google-oauth2, omniauth-facebook, omniauth-vkontakte
  • Ruby Version: 3.0.2
  • Framework: ruby on rails 6.1.4.1
  • Platform: macOS

Expected Behavior

It should allow to login using Google, Facebook, and Vk

Actual Behavior

Exception NoMethodError undefined method `provider' for nil:NilClass and request.env['omniauth.auth'] is nil in OmniauthCallbackController

Steps to Reproduce

Create app from any rails template https://github.com/alec-c4/kickstart for example

rails new test_application --no-skip-hotwire -T -c bootstrap -j esbuild -d postgresql -m https://raw.githubusercontent.com/alec-c4/ks-rails-bootstrap/master/template.rb

add creadentials

active_record_encryption:
  primary_key: ''
  deterministic_key: ''
  key_derivation_salt: ''
secret_key_base: ''
devise:
  secret_key: ''
google:
  client_id: ''
  client_secret: ''
postmark:
  api_key: ''

and try to login using Google