Help with the ruby OAuth2 gem please: "resource not found"

Hi - I’m sure I’m missing something really obvious - but I’m using the OAuth2 gem with Ruby 2.4.1 to try and connect to the FreeAgent API and I get a “resource not found” error. I’ve never used the OAuth2 gem directly before so I’m just adapting their example code.

client = OAuth2::Client.new(client_id, client_secret, site: 'https://api.freeagent.com/v2/token_endpoint')
client.auth_code.authorize_url(:redirect_uri => 'http://localhost:3000/oauth2/callback')
# this returns a URL at api.freeagent.com containing my client_id, redirect URL and response_type=code
auth = Base64.strict_encode64("api-email:api-password")
token = client.auth_code.get_token('authorization_code_value', :redirect_uri => 'http://localhost:3000/oauth2/callback', :headers => {'Authorization' => "Basic #{auth}", 'Accept' => 'application/json'})
# OAuth2::Error: :{"errors":{"error":{"message":"Resource not found"}}}

Any idea what I’m missing?

Thanks in advance,
Baz