Hi @Valeriia Kalynenko ,
Since your code worked well before, there might something error with your account. Please check the following steps
- Check the permission to the the site. You can refer to the article .
- Check if the tenant have enabled MFA. You can refer to the document Set up multifactor authentication for Microsoft 365
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.