This example elaborates on how to build a request for Xero's token migration endpoint, in order to swap an OAuth1.0a access token for a new set of OAuth2 access & refresh tokens.
It's a .Net Core 3.0 application, but the flow should be clear enough that it can be applied to your language/framework of choice. Note the code has been optimised for clear understanding of the flow, and is not intended to be used as-is in a production environment.
It assumes you've already created OAuth2 credentials for your app at https://developer.xero.com/myapps
In appsettings.json, update the following values:
offline_access
scope.Build the solution
Select an access token for one of your already-connected-to-Xero-via-OAuth1.0a organisations
Open a terminal window in the /bin
folder and run dotnet Xero.Api.Migrate.Core.dll {YOUR_ACCESS_TOKEN}
You should see the OAuth2 access & refresh tokens, and the organisations for which the tokens apply, listed in the terminal window.