Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the gem to the project changes the Content-Type of http response to my GraphQL API #103

Open
jivea opened this issue Oct 31, 2023 · 2 comments

Comments

@jivea
Copy link

jivea commented Oct 31, 2023

Hello,
First of all, thank you for this very usefull and time saving gem.
Thanks to it, I could integrate MFA with Authenticar apps.

However, when deploying the feature to the testing environement, it appeared to break the JSON API of the project.
I could more or less isolate the problem that I can describe like this:

  • Beside the usual web application, my Ruby on rails project runs an http API that inherits from ActionController::API.

  • Simply adding the gem to the Gemfile changes the behaviour of this API: the Content-Type header of the response is set to 'text/plain' instead of 'application/json' and the returned data is empty. This causes api clients to break.

  • If I comment the following lines of the gem, the Content-Type header is back to 'application/json', the data is OK and the API is fixed.
    lib/google-authenticator-rails/action_controller/rails_adapter.rb, lines 44 ->46

if defined?(ActionController::API)
ActionController::API.send(:include, GoogleAuthenticatorRails::ActionController::Integration)
end

I am pretty novice to Ruby on Rails and I have to admit that I don't understand much of what's going under all this.

Do you have an idea of how I could fix or workaround the problem ?

@jivea
Copy link
Author

jivea commented Nov 24, 2023

Hi @jaredonline, any thoughts on this topic?
What if I submit a pull request that adds a setting "Apply on API" ? Any chance to get it merged?

@jaredonline
Copy link
Owner

Heya @jivea sorry I've been slow to respond - I don't spend a lot of time on this project anymore.

I'm not really sure why adding the gem would change the response type of your API responses... I haven't encountered that before and there isn't anything in the project that should do that.

What version of Rails/Ruby/Bundler are you using? What other gems are in your gemfile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants