Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

ouath/Flask authentication invalid request

Started by Matthew Vincent -   in API Authentication


I am trying to build a simple flask app to connect to Xero, where I can then see transaction data etc.

I am using the requests_oauthlib library however when loading https://login.xero.com/identity/connect/authorize I keep getting a 500 error (invalid request : invalid redirect uri).

For the purposes of testing I am running this locally on localhost and so have a redirect uri in the app settings as https://localhost:5000/callback

I also have a 'callback' route in my app so I'm not sure why this is happening. Are you able to please assist?
Hi Matthew.

We've actually got a simple flask starter app using our xero-python SDK you might want to checkout: https://github.com/XeroAPI/xero-python-oauth2-starter

However your error is likely the callback URI not mating 100%


Should probably match to http://localhost:5000/callback

http :)

Christopher Knight (Xero Staff)  

Hi Christoper,

Thanks for your reply. I did actually use the xero-python library before which was handy however this time I'm trying to build my an app which mimics what Zapier does i.e. every hour, login to xero and pull transactions.

Just need the oauth authentication to work however can't figure out the redirect_uri. I don't think it can be http://localhost:5000/callback since Xero has to use https doesn't it?

Matthew Vincent  

Yes https is required except for localhost.


The main thing is that the authorize url callback uri has to 100% match on of the whitelist of callback URI's in your myapps dashboard as that is an OAuth2.0 security feature.

If you make sure they are matched (even a trailing slash!) this should resolve.

Christopher Knight (Xero Staff)