Open
Description
I've seen this error elsewhere in the docs, but haven't seen anyone else trying to use Devise.
Found a similar issue on Stackoverflow.
Every request to Spotify returns with an error:
invalid_credentials: OAuth2::Error, invalid_grant: Invalid redirect URI {"error":"invalid_grant","error_description":"Invalid redirect URI"}
I have omniauth-spotify (0.0.9) and Devise (4.1.1) installed in my rails + angular application.
in devise.rb
config.omniauth :spotify, ENV["spotify_client_id"], ENV["spotify_client_secret"], scope: 'user-top-read user-read-email'
user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, :omniauth_providers => [:spotify]
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
end
end
end
routes.rb
Rails.application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
resources :genres
resources :artists
root 'static#index'
My redirect URI is set for my Spotify app:
http://localhost:3000/users/auth/spotify/callback
Any ideas would be great. Let me know if you need any more information.
Metadata
Metadata
Assignees
Labels
No labels