views:

22

answers:

0

I'm having trouble figuring out how to write an REST API using OAuth authentication. The actual authentication part is working fine, but I'm not sure how to access the OAuth token in order to find the associated user.

Here is the (barebones) code that I am currently working with in my controller:

class UsersController < ApplicationController

  before_filter :oauth_required

  def credentials
    render :json => User.find(current_token[:user_id]).to_json( :only => [ :id, :email ] )
  end

end

However, current_token doesn't seem to be the correct method to use, as it's currently returning nil. I can't figure out if the code above is wrong, or if something is problematic somewhere else in the application.