Hi @Vasileios Klouvatos ,
Per my test, this way to get the access token works fine on my end. You could share the code you use so I could help you more.
Below is my demo code:
private static async Task<string> GetATokenForGraph()
{
string applicationId = "xxxx";
string tenantId = "contoso.onmicrosoft.com";
IPublicClientApplication confApp = PublicClientApplicationBuilder.Create(applicationId)
.WithAuthority($"https://login.microsoftonline.com/{tenantId}")
.Build();
var userName = "michael@contoso.onmicrosoft.com";
var password = "xxx";
var securePassword = new SecureString();
foreach (char c in password)
securePassword.AppendChar(c);
var scopes = new string[] { "user.read" };
var authenticationResult = await confApp.AcquireTokenByUsernamePassword(scopes, userName, securePassword).ExecuteAsync();
return authenticationResult.AccessToken;
}
If an Answer is helpful, please click "Accept Answer" and upvote it.
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.