I need to write a Batch Apex that does DML and multiple callouts at different points in the process, then chains to another batch that also does DML and multiple callouts. Here's how I plan to do it, but is there a step where I might run into "uncommitted work pending" or "Callout from scheduled Apex not supported" problems?
The batch will be Stateful and AllowsCallouts.
In the start method, check if an Oauth2 token refresh is needed. If so, make a callout to get the new token, then save the new token to custom settings.
In the execute method, make a callout to create an object in the external system. I may need to create multiple objects of this type, so I will set the batch scope to 1. Place the object ID in a stateful collection. Don't do any DML.
In the finish method, write the external system object IDs to a Salesforce custom object and update a timestamp in custom settings, and chain to another batch file. This second batch file will do the same steps for a different external object.
In particular I'm wondering if a chained batch is considered "scheduled Apex" because that would break the second batch's functionality.
Do you think this should work?