0

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 Answer 1

0

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/

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, my powershell script launch a login window, where I enter my username and password and after that I am getting the above posted error related to MFA. I will try the "device code flow" as you suggested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.