An API that connects multiple Microsoft services, enabling data access and automation across platforms
According to the code, you are using ROPC flow, so you can use the SDK for authentication.
Detailed authentication codes can be found in this document:
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.