Search code examples
oauth-2.0tokenquickbooks-onlineintuit-partner-platform

InvalidFieldFormat when obtaining token from intuit quickbooks


When I try to call:

POST /oauth2/v1/tokens/bearer?grant_type=authorization_code&code=XXX&redirect_uri=https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl

Content-Type: application/x-www-form-urlencoded Accept: application/json Authorization: Basic XXX I get Status: 400 Code: InvalidFieldFormat Type:SYSTEM from every platform (curl, postman, mongodb stitch). The only place where it works is the intuit playground. I do not see what is invalid.


Solution

  • You're trying to pass everything via a query string, and you should be passing it in the POST body.

    You should be POSTing to this URL: https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer

    And passing in a HTTP request body like this:

    grant_type=authorization_code&
    code=L3114709614564VSU8JSEiPkXx1xhV8D9mv4xbv6sZJycibMUI&
    redirect_uri=https://www.mydemoapp.com/oauth-redirect
    

    It's the POST body, not the query string.

    This is documented on Intuit's site here: https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0#step-5-exchange-authorization-code-for-refresh-and-access-tokens