bigcommerce / omniauth-bigcommerce

OmniAuth Bigcommerce Strategy
https://developer.bigcommerce.com
MIT License
15 stars 28 forks source link

omniauth.auth nill #27

Open DavidLSO opened 3 years ago

DavidLSO commented 3 years ago

Guys I'm having this problem when trying to perform authentication using lib version omniauth-bigcommerce (0.3.3)

/config/initializers/omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :bigcommerce, ENV['BC_CLIENT_ID'], ENV['BC_CLIENT_SECRET'],
  {
    scope: "store_payments_methods_read store_stored_payment_instruments_read_only store_v2_content_read_only store_v2_customers_read_only store_v2_default store_v2_orders_read_only store_v2_products_read_only store_v2_transactions_read_only users_basic_information",
    client_options: {
      site: 'https://login.bigcommerce.com'
    }
  }
end

config/routes.rb

get '/oauth' => 'omniauths#callback'
get '/load' => 'omniauths#load'
get '/uninstall' => 'omniauths#uninstall'

app/controllers/api/v1/omniauths_controller.rb

class Api::V1::OmniauthsController < Api::V1::BaseController
  skip_before_action :validate_access_token, only: [:callback, :uninstall, :load]

  def callback
    auth = request.env["omniauth.auth"] # nill ever
  end
end
j05h commented 3 years ago

@DavidLSO ensure you support bot GET and POST operations. The routes changes you have imply you have only done GET.

You should also ensure you have the session middleware configured as documented:

https://github.com/omniauth/omniauth#integrating-omniauth-into-your-rails-api

You'll need to make sure you pass the name of your session key.

config.session_store :cookie_store, key: '_david_slo_session'

DavidLSO commented 3 years ago

I took a look at the omniauth project and saw that this problem is occurring there, I put the link below

https://github.com/omniauth/omniauth/issues/921

@j05h

j05h commented 3 years ago

What are your settings for omniauth in config/application.rb?

And what version of Rails are you using? I noticed in that ticket you referenced specific configurations for Rails 6.1