Adding an extra param to auth0 call

auth0 ruby gem → omniauth-auth0

This is a clarification of usage, I need to send an extra param in the request to auth0 which will be used in a custom rule. For example if the new param is called ‘foobar’ is this the correct way to pass it to auth0:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider(
      :auth0,
      ENV['AUTH0_CLIENT_ID'],
      ENV['AUTH0_CLIENT_SECRET'],
      ENV['AUTH0_DOMAIN'] ,
      callback_path: '/auth/auth0/callback',
      provider_ignores_state: true,
      authorize_params: {
          scope: 'openid email profile',
          foobar: 'myvalue'
      }
  )
end

Button:
<%= button_to 'Login','auth/auth0', method: :post, class: 'btn btn-primary btn-lg' %>

Hi @bingobangobongo ,

Are you requesting a review or sharing your findings? If the latter, thanks for the contributions! Otherwise, I’d be happy to take a look.

I am looking for some help, if the code I provided is the correct way to provide and extra param to Auth0 which is then used in a rule.

In the authorize params I have provided a custom attribute (foobar) with a value of ‘myvalue’. Is this the correct way to do this?

Thanks

This looks correct to me. Is it not working for you? Here it is stated in the docs:

https://www.rubydoc.info/gems/omniauth-auth0/OmniAuth/Strategies/Auth0#authorize_params-instance_method

1 Like

Yes it is working I was finally able to test it. The docs were not clear that this was the correct approach so I am happy to have it verified.

Thanks.

1 Like

Great! Thanks for following up. :grinning_face_with_smiling_eyes:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.