Password Generation - MS Graph

Ayan Usmani 141 Reputation points
2022-10-30T13:59:12.453+00:00

I am creating a user using MS API to create user. While doing so I am randomly generating a password via my python script which is being send in the api request body.

But it fails due to password not complying the complexity.

Is there any way to get random password genearated from MS api OR any suggested library in python which complies with MS password complexity policy.

Microsoft Graph Users API
Microsoft Graph Users API
A Microsoft API that allows you to build compelling app experiences based on users, their relationships with other users and groups, and the resources they access for example their mails, calendars, files, administrative roles, group memberships.
726 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dillon Silzer 40,031 Reputation points
    2022-10-30T19:50:52.22+00:00

    Hi @Ayan Usmani

    Password requirements:

    255407-image.png

    Cited from https://learn.microsoft.com/en-us/azure/active-directory/authentication/concept-sspr-policy

    Python:

    import random  
    import string  
      
    # get random password pf length 8 with letters, digits, and symbols  
    characters = string.ascii_letters + string.digits + string.punctuation  
    password = ''.join(random.choice(characters) for i in range(8))  
    print(password)  
    

    Cited from https://pynative.com/python-generate-random-string/

    Reference to Create User (Graph API):

    https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=http

    -------------------------------------------

    If this is helpful please accept answer.

    0 comments No comments

0 additional answers

Sort by: Most helpful