Skip to content

Commit

Permalink
Add Rake task to get Spotify access token
Browse files Browse the repository at this point in the history
For faster local debugging by hitting the Spotify API via curl commands.
  • Loading branch information
cheshire137 committed Apr 16, 2017
1 parent 4fb25a3 commit a213af9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Rakefile
Expand Up @@ -8,3 +8,23 @@ namespace :generate do
puts SecureRandom.hex(64)
end
end

namespace :spotify do
desc 'Get an access token for the specified user_name'
task :access_token, [:user_name] do |t, args|
user = User.find_by_user_name(args[:user_name])

unless user
puts "No user exists with user_name #{args[:user_name]}"
next
end

if user.update_spotify_tokens
puts "#{user.user_name}'s access token:"
puts user.spotify_access_token
else
puts "Failed to update #{user.user_name}'s access token:"
puts user.errors.full_messages.join(', ')
end
end
end

0 comments on commit a213af9

Please sign in to comment.