There is no OAuth flow that allows you to do that (password grant works only in your AD) and
basic authentication is being removed.
In other words: you no longer need or are allowed to know user's password.
You need to switch to proper OAuth 2.0 flow, as shown in the article in your question:
Users log-in once, you store access and refresh tokens, and use those on subsequent request. There is no need to save and store user's password.