0
votes

I am working on Microsoft Graph with powershell script.

I am using authorization grant flow to get the access token to retrieve the emails from a shared mailbox using my user account, whenever I provide my login credentials, its giving me below error related to the MFA.

Invoke-RestMethod : {"error":"invalid_grant","error_description":"AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '00000003-0000-0000-c000-000000000000'

Is there any way to launch a MFA authentication window from powershell script?

Any help or example is appreciated.

1

1 Answers

0
votes

You say “you provide credentials”, do you mean you’re setting the username and password in powershell?

You have several ways, it would suggest to use the “device code flow”. Then the login part is done in the browser, where you have all those multi-factor things configured.

Someone made a great blog about it, https://blog.simonw.se/getting-an-access-token-for-azuread-using-powershell-and-device-login-flow/