Hi @Anonymous
For security, the Graph api will not return any user's password for you including your own.
If you want to authenticate the username and password, I suggest you can use the ROPC flow, which will return an access token if the username and password are correct.
var scopes = new[] { "Mail.ReadWrite" };
// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "{tenant id}";
// Value from app registration
var clientId = "{client id}";
// using Azure.Identity;
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var userName = "username";
var password = "password";
// https://learn.microsoft.com/dotnet/api/azure.identity.usernamepasswordcredential
var userNamePasswordCredential = new UsernamePasswordCredential(
userName, password, tenantId, clientId, options);
var accessToken = await userNamePasswordCredential.GetTokenAsync(new TokenRequestContext(scopes) { });
Console.WriteLine("token:" + JsonConvert.SerializeObject(accessToken.Token));
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.