1

How do you get the URL that OmniAuth redirect to when you go to /auth/twitter?

I am building an API server and just want to pass the URL in JSON to the client so it can do whatever it needs to with the URL.

I think what I want is the result of the strategy's request_phase as that looks to be the auth URL, but how do I get that in a new controller so I can do:

class MyOauthController < ApplicationController
  # GET /my_oauth/signin/twitter.json
  def signin
    url = ???
    render json: {signin_url: url}
  end

Is there a clean way to do this?

Peter Sankauskas
  • 2,882
  • 4
  • 27
  • 28

1 Answers1

0

Yes, Omniauth provides a helper function for you:

user_omniauth_authorize_path(key)
# for your case
user_omniauth_authorize_path("twitter")

Check out their Devise overview.

Evan Hammer
  • 450
  • 4
  • 13