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

Any way to customize '/auth/:provider/callback' url? #593

Closed
sadfuzzy opened this issue Apr 10, 2012 · 13 comments
Closed

Any way to customize '/auth/:provider/callback' url? #593

sadfuzzy opened this issue Apr 10, 2012 · 13 comments

Comments

@sadfuzzy
Copy link

Any way to customize '/auth/:provider/callback' url?
Is there any way? I want this to separate mobile applications and browser(any) response in Rails.
Something like '/auth/(:client)/:provider/callback' in my routes.
One - '/auth/:provider/callback' for usual users(responds html).
Other - '/auth/mobile_app/:provider/callback' for ios/android(responds json, user auth_token).

@mbleigh
Copy link
Contributor

mbleigh commented Apr 12, 2012

You can customize the callback path like so:

provider :providername, :callback_path => "/auth/providername/mobile/callback"

@mbleigh mbleigh closed this as completed Apr 12, 2012
@sadfuzzy
Copy link
Author

In the initializer?

@sadfuzzy
Copy link
Author

Can i specify two callback paths, as i explained before? I still don't understand, sorry..

@adamgotterer
Copy link

@sadfuzzy did you ever figure this out?

@sadfuzzy
Copy link
Author

sadfuzzy commented Aug 8, 2013

@adamgotterer yeah, @mbleigh's answer worked for me

@shireeshj
Copy link

@sadfuzzy would be helpful if you can describe your solution.

I have somewhat similar situation. I am looking to use a single provider to authenticate two different types of users - say (1) employee and (2) customer. An elegant way, in my opinion, would be to use different callback urls for each user-type.

@rdetert
Copy link

rdetert commented Dec 3, 2013

I'm trying to do the same as @shireesh. I have two different types of users Customer and Vendor. I'd like to use the paths /customer/auth/:provider/callback and /vendor/auth/:provider/callback. Otherwise I'm not sure how to do single sign on with two different types of users from within the same app.

@adamgotterer
Copy link

I think its specific per omni auth provider. In Google oauth its redirect_to redirect_uri . Not sure how helpful this will be. But this is how I do it through devise.

 redirect_to user_omniauth_authorize_path(:google_oauth2, redirect_uri: ...)

@swaathi
Copy link

swaathi commented Jul 27, 2016

@sadfuzzy How did you go about this? If I put what @mbleigh suggested in an initializer it throws a undefined method 'provider' error. Anyone else figure this out?

@pbrueske
Copy link

@sadfuzzy You can use the OmniAuth::Builder in an initializer (see https://github.com/omniauth/omniauth#getting-started) to set a custom callback path:

# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :providername, :callback_path => "/auth/providername/mobile/callback"
end

@nantestdeveloper
Copy link

nantestdeveloper commented Nov 30, 2017

I want to call the api post call url http://localhost:3000/api/v1/auth/identity/callback .please help me to understand how can I customize the post call and routes .so the in return will get success status ,because while calling post call like "http://localhost:3000/api/v1/auth/identity/callback " not able to generate the auth_hash and getting error in postman

NoMethodError at /api/v1/auth/identity/callback

===============================================

undefined method `[]' for nil:NilClass

@twoneks
Copy link

twoneks commented Sep 26, 2019

What if I need to set a callback url that is external to my rails app domain?
The option callback_path only allow custom path in the scope of the application.

@jbranchaud
Copy link

What if I need to set a callback url that is external to my rails app domain?
The option callback_path only allow custom path in the scope of the application.

@twoneks I'd recommend fielding the callback from your rails app and then redirecting to an external domain from there.

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

10 participants