When you need to use OmniAuth with Google on not registered domain in Google Developer console it's a crap.
For example if you would like to use Heroku review apps each time you need to register new domain in the Developer Console to let OAuth work.
We could use this redirect proxy as a single point for callback which should be registered in Google Developer console.
Redirect proxy will catch up callback request from Google and redirect it back to application.
The trick is – application domain should be encoded with Base64 in the state
parameter.
So we will have following flow:
- User clicks on /auth/google_oauth2/?state=http://app-pr-1.herokuapp.com
- App redirects to Google
- User authenticates in Google
- Google redirects to redirect proxy
- Redirect proxy redirects to the http://app-pr-1.herokuapp.com/
In your app you need setup OmniAuth.config.full_host
to http://oauth-redirect-proxy.herokuapp.com
And encode request.base_url
with Base64.encode64
in to state
parameter.
Just deploy to Heroku as regular Ruby application
heroku create
git push heroku master
bin/setup
bin/quality
based on RuboCop.rubocop.yml
describes active checks
bin/build
checks your specs and runs quality tools
Ruby Base is maintained by Timur Vafin. It was written by Flatstack with the help of our contributors.