Question: Been fighting this one all morning. Here are the links I have been pointed to and I am still having no luck:

<http://www.asp.net/visual-studio/overview/2013/release-notes-(release-candidate)>

<https://stackoverflow.com/a/18426574/1118218> (I did everything the accepted answer suggests)

<https://stackoverflow.com/a/18419011/1118218> (same question as above, but the solution here did not work either, does not resolve the classes)

I installed the ASPNET web tools refresh. Restarted visual studio. Everything seems to build correctly except for the AccountController. It cannot find AuthenticationIdentityManager(and IdentityStore). 

```
[Authorize]
public class AccountController : Controller
{
    public AccountController()
    {
        IdentityManager = new AuthenticationIdentityManager(new IdentityStore());
    }

    public AccountController(AuthenticationIdentityManager manager)
    {
        IdentityManager = manager;
    }

    public AuthenticationIdentityManager IdentityManager { get; private set; }
}

```

Any idea how to get this to work? All the nuget packages related to ASP.NET Identity, Owin, EF, and MVC are updated to the latest pre-release version.

Answer: 
I have a few techniques that I use to deal with this stuff.

The first is to use plain ruby methods over `let`. This is just my preference, I think it adds clarity to tests. Check this for more about that: <http://robots.thoughtbot.com/lets-not>

And then, I have a helper method for auth stuff. I'm using Devise for authentication, so my implementation will be different than yours, but this sets the HTTP\_AUTHORIZATION header for every request made to my app after calling the helper method in the tests.

```
module Requests
  module AuthenticationHelpers
    def basic_http_auth(user)
      credentials = ActionController::HttpAuthentication::Basic.encode_credentials(user.email,user.password)
      Rack::MockRequest::DEFAULT_ENV['HTTP_AUTHORIZATION'] = credentials
    end
  end
end

```

And then in the actual test, I'll do something like this:

```
describe "GET /api/v1/messages" do
  it 'returns an array of messages' do
    get '/api/v1/messages'
    basic_http_auth(FactoryGirl.create(:user))

    expect(response).to eq(200)
  end
end

```

So, if you're going to be using this across a lot of the API tests, move it into a support helper. And, if you're calling something multiple times in the same file, write a method (or put it in a `let` call) to DRY your your tests.
Building on Matthew's answer, with Doorkeeper, I ended up using the following:

```
module TokenMacros
  def generate_access_token_for(user = nil)
    user ||= FactoryGirl.create(:user)
    authentication = FactoryGirl.create(:authentication, user: user)
    application = Doorkeeper::Application.create!(:name => "MyApp", :redirect_uri => "http://app.com")
    access_token = Doorkeeper::AccessToken.create!(:application_id => application.id, :resource_owner_id => authentication.identity.id)
    access_token.token
  end
end

```

which then allows me to call...

```
let(:user) { FactoryGirl.create(:user) }
let(:token) { generate_access_token_for(user) }

```

splendid