Password Generation - MS Graph

Ayan Usmani 171 Reputation points

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
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,124 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dillon Silzer 54,931 Reputation points

    Hi @Ayan Usmani

    Password requirements:


    Cited from


    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))  

    Cited from

    Reference to Create User (Graph API):


    If this is helpful please accept answer.

    0 comments No comments

0 additional answers

Sort by: Most helpful