In Power BI desktop, you can access the all database and save the credential in cache at the first time to connect. When connecting next time, you don't have to input credential again.
Why that much interaction with Power BI desktop? There's no any programming API for Power BI desktop.
Based on my understanding on your requirement, Power BI Embedded seems promising. You can set SetAllConnections to decide which DB is connected according to the connecting user.