Authentication - Can't get access token

Hi team,

I am trying Free Agent for the first time.

  1. I followed the Authorization documentation and managed to get the authorization code.
  2. When I try to get the access token, I get the below error message which is very strange (I am not using any API required for accountants). I must be doing something really silly, but I can’t seem to figure out what it is.

Looking forward to hear from you.

Cheers,
Dhanya

Hi Dhanya,

Thanks for your message and welcome to our API forum :wave: Based on the screenshot you so helpfully provided, it looks like your POST request was made to the oauth2.googleapis.com/token URL, rather than to the FreeAgent server. Could you try using this custom link to the Goole OAuth 2.0 playground which includes all the required configuration (apart from the OAuth Client ID and OAuth Client secret which you’ll have to populate with details from your app registered on the FreeAgent Developer Dashboard) and see how you get on?

https://developers.google.com/oauthplayground/#step3&url=https%3A//&content_type=application/json&http_method=GET&useDefaultOauthCred=unchecked&oauthEndpointSelect=Custom&oauthAuthEndpointValue=https%3A//api.sandbox.freeagent.com/v2/approve_app&oauthTokenEndpointValue=https%3A//api.sandbox.freeagent.com/v2/token_endpoint&includeCredentials=unchecked

Best wishes,

Ewa

Hi Ewa,

Thanks a lot for the quick response much appreciated. I have used the URL you mentioned and updated it with the client and secret. Now I am unable to get Authorization code. I get the error no request.


https://developers.google.com/oauthplayground/#step2&url=https%3A%2F%2Fapi.freeagent.com%2Fv2%2Fbills&content_type=application%2Fjson&http_method=GET&useDefaultOauthCred=unchecked&oauthEndpointSelect=Custom&oauthAuthEndpointValue=https%3A%2F%2Fapi.sandbox.freeagent.com%2Fv2%2Fapprove_app&oauthTokenEndpointValue=https%3A%2F%2Fapi.sandbox.freeagent.com%2Fv2%2Ftoken_endpoint&oauthClientId=*****&oauthClientSecret=&includeCredentials=checked&accessTokenType=bearer&autoRefreshToken=unchecked&accessType=offline&prompt=consent&response_type=code&wrapLines=on

Screen Shot 2020-10-07 at 14.00.38

Hi Dhanya,

After visiting this link, clicking OK! That’s fine. on the pop-up asking whether you want to keep the custom configuration, and populating the OAuth Client ID and OAuth Client secret fields, what happens when you click on Select and Authorize APIs, input any value in the scope field, and click Authorize APIs? You should be redirected to the FreeAgent login page, and provided with an authorization code after a successful sign-in to your FreeAgent Sandbox account.

You’ll then be redirected to the FreeAgent login screen.

Screenshot 2020-10-07 at 17.14.30

After logging in and approving your app, you’ll come back to the Google OAuth Playground, where you can exchange the Authorization Code for an Access Token:

I hope this helps!

Best wishes,

Ewa