Getting Started with the Rails oAuth2 gem

I’m quite new to the FreeAgent APi, but I’ve successfully worked with other
oAuth-based APIs before without too many problems, but I’m struggling to
find my way around this.

Using the code example snippets from the oAuth2 gem GitHub page
(, I’ve created just two lines of code
that should generate the “authorize URL”, but when I click the link they
generate, I get the following error;

"Format not recognised. Set accept http header to application/json or 


In the controller, I’ve included (with my variables changed);

freeagent_api =, client_secret, :site =>’)
@oauth_url = freeagent_api.auth_code.authorize_url(:redirect_uri =>’)

And in the view, a simple

=link_to "Connect with FreeAgent", @oauth_url

This seems pretty self-explanatory, but I’ve not encountered this before,
using other APIs this way, so I’m not sure what the correct way to add
these to the code Rails uses for this is.

Has anyone overcome this before?

Any help would be much appreciated!