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_...
VasilMichev
Mar 28, 2023MVP
Not sure where you got this code, but there is no /users/$userId/authentication/strongAuthenticationMethods endpoint. The correct one should be /users/$userId/authentication/Methods, or if you are looking for the report instead, /reports/credentialUserRegistrationDetails.
The token part looks fine, but make sure the permissions are correctly reflected in the obtained access token. You can parse it with tools such as jwt.ms.
The token part looks fine, but make sure the permissions are correctly reflected in the obtained access token. You can parse it with tools such as jwt.ms.
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
- VasilMichevMar 28, 2023MVPChatCPT 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- 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?