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

No route matches [GET] "/auth/spotify" #243

Closed
fakefarm opened this issue Dec 13, 2021 · 1 comment
Closed

No route matches [GET] "/auth/spotify" #243

fakefarm opened this issue Dec 13, 2021 · 1 comment

Comments

@fakefarm
Copy link

fakefarm commented Dec 13, 2021

Hello, thank you for a great GEM!

I'm having trouble firing the request for for user auth. Any suggestions why I'm getting:
No route matches [GET] "/auth/spotify"?
(This is a clean install of rails (7.0.0.rc1) ​to try out RSpotify.)

# application.html.erb
<%= link_to 'Sign in with Spotify', '/auth/spotify' %>
# routes.rb
get '/auth/spotify/callback', to: 'users#spotify'
# works in rails c
>  RSpotify::authenticate("secret", "secret")
=> true
# have a user
$ rails g scaffold users email username
# added initializers
require 'rspotify/oauth'

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :spotify, "mycreds", "mycreds", scope: 'user-read-email 
playlist-modify-public user-library-read user-library-modify'
end
# added to application.rb
RSpotify::authenticate("cred", "cred")
@fakefarm
Copy link
Author

Update / Solved.

I solved it by doing the following 2 things:

1. I changed the link...

from:

# mentioned in README
<%= link_to 'link in with Spotify', '/auth/spotify' %>

to:

<%= button_to 'Sign in with Spotify', '/auth/spotify' %>

Sidenote:

I tried to add the method: post to link_to but it didn't take. (Maybe User Error)

# This didn't work for me..
   <%= link_to 'link in with Spotify', '/auth/spotify', method: 'post' %>

2. Added the following gems:

gem "omniauth-rails_csrf_protection"
gem 'omniauth-spotify-oauth2', '~> 1.0'

Does this seem right to you? If so, I'd be happy to submit a PR to update README (if that helps.)

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

1 participant