Forum Discussion
StevenRPF
Mar 28, 2023Brass Contributor
Get MFAStatus with API
Hi, I'm trying to get a report for the MFA status for all my tenant users. # Replace the values in the following variables with your own
$clientId = "your_client_id_here"
$clientSecret = "your_...
StevenRPF
Mar 28, 2023Brass Contributor
To be honnest, this code is from ChatGPT! 🙂 You understand that I'm not a professionnal in powershell!! 🙂
I tried you modification and same error at same line .... like if I have an authorization problem.
Can you give me a cue to check if my authentication and permission are good with the API?
THanks
I tried you modification and same error at same line .... like if I have an authorization problem.
Can you give me a cue to check if my authentication and permission are good with the API?
THanks
VasilMichev
Mar 28, 2023MVP
ChatCPT is smoking something good, again... 🙂
Let's start with the basics, did you create an app registration and grant the permissions? In other words, are you populating the variables with the correct values?
$clientId = "your_client_id_here"
$clientSecret = "your_client_secret_here"
$tenantId = "your_tenant_id_here"
Double- and triple-check if everything is OK there. Once you run the following:
$accessToken = $tokenResponse.access_token
you can do another check - decode the token and make sure the required permissions are correctly reflected therein. To do so, copy the token and head over to https://jwt.ms to decode it. You can copy it directly via:
$accessToken | clip
Let's start with the basics, did you create an app registration and grant the permissions? In other words, are you populating the variables with the correct values?
$clientId = "your_client_id_here"
$clientSecret = "your_client_secret_here"
$tenantId = "your_tenant_id_here"
Double- and triple-check if everything is OK there. Once you run the following:
$accessToken = $tokenResponse.access_token
you can do another check - decode the token and make sure the required permissions are correctly reflected therein. To do so, copy the token and head over to https://jwt.ms to decode it. You can copy it directly via:
$accessToken | clip
- StevenRPFMar 28, 2023Brass Contributorwhen I past nothing appear ... does it means I have a permission problem or clientID secret?!?! I've tripple-checked but ... maybe something wrong in my app registration?!
- VasilMichevMar 29, 2023MVPMight be. Which permissions did you add, and did you grant admin consent?
- StevenRPFMar 29, 2023Brass Contributoryes I grand admin consent ... and I grand all permission specified above :
UserAuthenticationMethod.Read.All or UserAuthenticationMethod.ReadWrite.All (for Microsoft Graph API v1.0) OR AuthenticationMethod.Read.All or AuthenticationMethod.ReadWrite.All (for Microsoft Graph API beta)
User.Read.All or User.ReadWrite.All (for Microsoft Graph API v1.0) OR Directory.Read.All or Directory.ReadWrite.All (for Microsoft Graph API beta)
Can I check some log in Azure Admin Center or other way to check if my request are accepted? To be sur client ID password are ok?
Is this normal I got nothing when I past in the token decoder?
Thanks again