How to programmatically add and configure provider to the users-permissions plugin?

Config Sync plugin is probably your best bet.