-
Notifications
You must be signed in to change notification settings - Fork 41
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
Define redirect endpoint #31
Comments
@SimonLab the point of having a hard-coded callback endpoint is to have a "sensible default". Having a callback of I can see the appeal to make this configurable but I don't understand why the Phoenix App cannot simply use the existing callback URL? What is the use-case for making the callback URL something different? |
While adding the package to the Phoenix app, I've created the callback endpoint under the `api`` scope as I only have api endpoints at the moment on my router.ex: scope "/api", AuthApiWeb do
pipe_through :api
get "/auth/google/callback", GoogleAuthController, :index
get "/auth/github/callback", GithubAuthController, :index
get "/auth/urls", AuthUrlController, :index
end I can remove the endpoint from the scope but it felt strange to seperate the endoints as I consider them to be apis: scope "/", AppApiWeb do
pipe_through :api
get "/auth/google/callback", GoogleAuthController, :index
get "/auth/github/callback", GithubAuthController, :index
end
scope "/api", AppApiWeb do
pipe_through :api
get "/auth/urls", AuthUrlController, :index
end I understand it adds a bit more complexity to the package, however we still have the default redirect with def generate_oauth_url(conn) do
client_id = System.get_env("GOOGLE_CLIENT_ID")
scope = System.get_env("GOOGLE_SCOPE") || "profile email"
redirect_uri = generate_redirect_uri(conn)
"#{@google_auth_url}&client_id=#{client_id}&scope=#{scope}&redirect_uri=#{redirect_uri}"
end and if user wants to specify another endpoint they can call def generate_oauth_url(conn, callback_endpoint) do
client_id = System.get_env("GOOGLE_CLIENT_ID")
scope = System.get_env("GOOGLE_SCOPE") || "profile email"
redirect_uri = generate_redirect_uri(conn, callback_endpoint)
"#{@google_auth_url}&client_id=#{client_id}&scope=#{scope}&redirect_uri=#{redirect_uri}"
end However this feature is not a blocker for me. |
@SimonLab do we need to have separate endpoint for API? |
I'm not sure what you mean. |
Can we just use content negotiation to switch between HTML and JSON handlers based on the content type of the request? i.e. use the same route for both API and Browser (HTML) requests. |
Yes we can use plug and My controller link to the redirect url doesn't returns any html (only json). I just wanted to have this endpoint matching the same naming as the other api endpoint (starting with I can see that it add more code than needed for now, so I'm closing this issue/PR |
The callback endpoint is currently hardcoded with:
I propose that we have an option to let the user define this callback url:
The text was updated successfully, but these errors were encountered: