abhidsm / devise-token-api

Token based authentication for API using Devise
66 stars 27 forks source link

Support latest vesion of devise #4

Open eshaiju opened 9 years ago

eshaiju commented 9 years ago

My gemfile.lock

GEM remote: https://rubygems.org/ specs: actionmailer (4.0.0) actionpack (= 4.0.0) mail (~> 2.5.3) actionpack (4.0.0) activesupport (= 4.0.0) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) activemodel (4.0.0) activesupport (= 4.0.0) builder (~> 3.1.0) activerecord (4.0.0) activemodel (= 4.0.0) activerecord-deprecated_finders (~> 1.0.2) activesupport (= 4.0.0) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) activesupport (4.0.0) i18n (~> 0.6, >= 0.6.4) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) arel (4.0.2) bcrypt (3.1.7) builder (3.1.4) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) coffee-script (2.3.0) coffee-script-source execjs coffee-script-source (1.8.0) devise (3.4.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) responders thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.2.5) erubis (2.7.0) execjs (2.2.2) factory_girl (4.5.0) activesupport (>= 3.0.0) factory_girl_rails (4.5.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) haml (4.0.5) tilt haml-rails (0.5.1) actionpack (~> 4.0.0) activesupport (~> 4.0.0) haml (>= 3.1, < 5.0) railties (~> 4.0.0) hike (1.2.3) i18n (0.6.11) jbuilder (1.5.3) activesupport (>= 3.0.0) multi_json (>= 1.2.0) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) libv8 (3.16.14.7) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) minitest (4.7.5) multi_json (1.10.1) mysql2 (0.3.16) orm_adapter (0.5.0) polyglot (0.3.5) rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) rails (4.0.0) actionmailer (= 4.0.0) actionpack (= 4.0.0) activerecord (= 4.0.0) activesupport (= 4.0.0) bundler (>= 1.3.0, < 2.0) railties (= 4.0.0) sprockets-rails (~> 2.0.0) railties (4.0.0) actionpack (= 4.0.0) activesupport (= 4.0.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.3.2) rdoc (4.1.2) json (~> 1.4) redis (3.1.0) ref (1.0.5) responders (1.1.1) railties (>= 3.2, < 4.2) rspec-core (3.1.7) rspec-support (~> 3.1.0) rspec-expectations (3.1.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.1.0) rspec-mocks (3.1.3) rspec-support (~> 3.1.0) rspec-rails (3.1.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) rspec-core (~> 3.1.0) rspec-expectations (~> 3.1.0) rspec-mocks (~> 3.1.0) rspec-support (~> 3.1.0) rspec-support (3.1.2) sass (3.2.19) sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0) sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) simple_form (3.0.2) actionpack (~> 4.0) activemodel (~> 4.0) spork (1.0.0rc4) sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sprockets-rails (2.0.1) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) tzinfo (0.3.41) uglifier (2.5.3) execjs (>= 0.3.0) json (>= 1.8.0) warden (1.2.3) rack (>= 1.0)

PLATFORMS ruby

DEPENDENCIES coffee-rails (~> 4.0.0) devise factory_girl_rails haml (>= 3.0.0) haml-rails jbuilder (~> 1.2) jquery-rails mysql2 rails (= 4.0.0) redis rspec-rails (>= 2.0.1) sass-rails (~> 4.0.0) sdoc simple_form (~> 3.0.0.rc) spork (~> 1.0rc) therubyracer uglifier (>= 1.3.0)

While starting server, getting error like this

uninitialized constant Devise::Models::TokenAuthenticatable (NameError)

excid3 commented 9 years ago

Token Authenticatable got refactored into a separate gem. You'll need to include that in your Gemfile as well.

gem 'devise-token_authenticatable', '~> 0.3.0'

https://github.com/baschtl/devise-token_authenticatable

christianstanfield commented 9 years ago

Hi, I was just trying this out today and adding the gem seems to work, but when I create a user (via a json post request to the Api::V1::RegistrationsController) the user is saved to the db but without an authentication token. This statement in the create method is evaluating true (if resource.active_for_authentication?) but I can't find that method to see what's going on?

marstherobot commented 8 years ago

Make sure you add the config file for TokenAuthenticatable and set 'config.should_ensure_authentication_token' to true. Default being false.

I know it's a bit of a late reply, but I hope it helps someone. Cheers