Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application permission: Send As email #428

Open
IgnacioMaestro opened this issue Apr 22, 2020 · 3 comments
Open

Application permission: Send As email #428

IgnacioMaestro opened this issue Apr 22, 2020 · 3 comments

Comments

@IgnacioMaestro
Copy link

In an app with Application permissions and credentials flow, I have Mail.Send.Shared permission. I want to send an email with the Send As mode. I mean, I have a shared mail box and I want to send an email from this mail box and I have another user with the permission to do that. Is it possible with python-0365?
I have tried that way:

    credentials = (client_id, client_secret)
    account = Account(credentials=credentials, auth_flow_type='credentials', tenant_id=tenant_id,
                      main_resource='user@my_company.com')
    if not account.is_authenticated:
        ok_auth = account.authenticate()
        if ok_auth:
            print('Authenticated!')
    if account.is_authenticated:
        message: Message = account.new_message()
        message.sender.address = 'shared_mailbox@my_company.com'
        message.to.add('another_user@my_compnay.com')
        message.subject = 'example subject'
        message.body = 'example message'
        message.send()

And I'm getting this error:
Client Error: 401 Client Error: Unauthorized for url: https://graph.microsoft.com/v1.0/users/user@my_company.com/sendMail | Error Message: The token contains no permissions, or permissions can not be understood.

@alejcas
Copy link
Member

alejcas commented Apr 22, 2020

Did you set application permissions or delegated?
Did the administrator approve your application permissions?

@IgnacioMaestro
Copy link
Author

Yes, I have an app created with application permissions and the administrator has approved them.

@alejcas
Copy link
Member

alejcas commented Apr 22, 2020

Then you don’t have the permissions required to send email as “ user@my_company.com

I mean you don’t have access to this user email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants