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

Always redirects to /auth/failure with message invalid_credentials #8

Open
alecguintu opened this issue Dec 18, 2015 · 7 comments
Open

Comments

@alecguintu
Copy link

Hello guys. I need to use omniauth-spotify but there seems to be an error I always get. It always redirects me to /auth/failure directly even before I get to do any puts on my callback action.

127.0.0.1 - - [18/Dec/2015 16:23:58] "GET /auth/spotify HTTP/1.1" 302 309 0.0523
127.0.0.1 - - [18/Dec/2015 16:24:00] "GET /auth/spotify/callback?code=AQDayxIRszbIYj_YQwCkYD3AYo2oDzKJVv9pl7zft54UjvaXccJCBGfc2e27J8aRDggirFK6H2mxXanE_OBTv9XVqoVGhw-5oFIJvD00448qVyzaNHAXanAnsx7_bPm5rbrrSFS12uNYVKpUT52hVH8OiEdXYxCjGqhAHDscCnoo5FY4u4ttTZHGDAGg9Y1tS6R0cdh5-Pc_HrPMzCGWR3qY_7WumIyJJJIsyvIMXzTeSP3rvt4j__BMZpN0rA6a-TwNAnGuW3fvIOQvO7PEagx4qvLK83issPev-LSG-A&state=da7dbbee0e89eb9a1abd9e6979b110936981eab12e5866a3 HTTP/1.1" 302 9 0.8371
127.0.0.1 - - [18/Dec/2015 16:24:00] "GET /auth/failure?message=invalid_credentials&origin=http%3A%2F%2Flocalhost%3A3000%2F42&strategy=spotify HTTP/1.1" 301 88 0.0491
127.0.0.1 - - [18/Dec/2015 16:24:00] "GET / HTTP/1.1" 302 - 0.0570

I have on my Spotify App is
callback: http://localhost:3000/auth/spotify/callback

I can provide more info if I need to.

@masterkain
Copy link
Member

can you show how are you initializing the gem? make sure to obscure used credentials.

@alecguintu
Copy link
Author

omniauth.rb

OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, ENV['TWITTER_CONSUMER_KEY'], ENV['TWITTER_CONSUMER_SECRET']
  provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], scope: 'public_profile', display: 'popup', info_fields: 'id,name,first_name,last_name,gender,about,bio,birthday,link'
  provider :spotify, ENV['SPOTIFY_CLIENT_ID'], ENV['SPOTIFY_CLIENT_SECRET'], scope: 'user-follow-modify user-read-private playlist-read-private'
end

# https://github.com/intridea/omniauth/wiki/FAQ#wiki-omniauthfailureendpoint-does-not-redirect-in-development-mode
# Open ticket on a better fix for this https://github.com/intridea/omniauth/issues/616
OmniAuth.config.on_failure = Proc.new { |env|
  OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}

Gemfile (Gems I'm using just in case):

gem 'omniauth-twitter', '~> 1.0'
gem 'twitter', '~> 4.8'
gem 'omniauth-facebook', '~> 3.0'
gem 'omniauth-spotify', '~> 0.0.9'

@alecguintu
Copy link
Author

Hello guys. First off, happy new year to you guys! Any leads to this? Any help would be appreciated.

@ross-alcazar
Copy link

I also have the same problem when i use facebook as login. I'd be happy to have a solution for this. thanks advance.

@dennislysenko
Copy link

+1, this is with 0.0.9. Any leads on this? The gem just flat out doesn't work for me at the moment.

@masterkain
Copy link
Member

can you try some of the potental workarounds listed here? #7 (comment)

@hannahhoward
Copy link

@masterkain it appears omniauth-oauth2 has permanently added the query string back to the callback_url in v1.4.0 and doesn't seem to be planning to remove it. other projects such as omniauth-google-oauth2 have permeantly locked on omniauth-oauth2 1.3.1 until it's fixed, or overriding the callback_url in the strategy. we resolved by manually setting a gem dependency for an early version of omniauth-oauth2. perhaps it's worth locking omniauth-spotify below 1.3.1 or overriding callback_url in the strategy?

sb8244 added a commit to SalesLoft/omniauth-salesloft that referenced this issue Feb 15, 2017
icoretech/omniauth-spotify#8 (comment)
zquestz/omniauth-google-oauth2#205

Google OAuth 2 talks about the problem with new Omniauth version's callback_url. Manually specific
the callback url to remove the query string
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

5 participants