Share via

Mail.ReadBasic.All can't create message subscriptions

HacheJulio 21 Reputation points
2022-03-10T11:21:15.313+00:00

I want to create user-specific subscriptions to messages using an Application (with Application permissions). I don't want to read the message's body so using the Mail.ReadBasic scope looks like the solution, but it doesn't work for Application permission, so I'm using "Mail.ReadBasic.All"

First, what I've found:

181904-captura-de-pantalla-de-2022-03-10-12-06-04.png

And now, what I have:

I have an app installed like this:

181898-captura-de-pantalla-de-2022-03-10-12-10-56.png

And when I try to create a new subscription for a user using the API (and Python) I get this error:

    payload = {  
        "changeType": "created,updated,deleted",  
        "notificationUrl": "https://<url>",  
        "resource": "/users/<user id>/messages",  
        "expirationDateTime": "2022-03-11T10:52:38Z",  
        "clientState": "testClientState",  
    }  
  
    graph_data = requests.post(  
        "https://graph.microsoft.com/beta/subscriptions/",  
        headers={  
            "Authorization": "Bearer " + access_token,  
            "Content-Type": "application/json",  
        },  
        json=payload,  
    )  


Graph API call result:   
{  
  "error": {  
    "code": "ExtensionError",  
    "message": "Operation: Create; Exception: [Status Code: Forbidden; Reason: Access is denied. Check credentials and try again.]",  
    "innerError": {  
      "date": "2022-03-10T10:54:50",  
      "request-id": "0db50e06-1b87-432b-b6d9-b83120c3de08",  
      "client-request-id": "<hidden>"  
    }  
  }  
}  

Using the same credentials (Applications Credentials using App Secrets) I can get that user profile info and the inbox messages list / specific message without any problem.

Is there something I am doing wrong? Is this a bug in the API scopes?

Thanks

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph

6 answers

Sort by: Most helpful
  1. Arunkumar Akuthota 26 Reputation points
    2022-06-02T13:46:22.033+00:00

    Did u see below error?

    Operation: Create; Exception: [Status Code: ServiceUnavailable; Reason: Target resource '00030000-d205-2a66-0000-000000000000' hosted on database '14adcc7b-33b0-418a-9cea-71ccf4592c21' is currently on backend 'Unknown']

    Was this answer helpful?

    0 comments No comments

  2. Arunkumar Akuthota 26 Reputation points
    2022-05-31T13:49:05.293+00:00

    After adding permissions on graph explorer, it is working. but still don't see a call back.

    I could see the call back for the validation token. but not for the notification request.

    Was this answer helpful?

    0 comments No comments

  3. Arunkumar Akuthota 26 Reputation points
    2022-05-31T06:30:25.093+00:00

    did you add which permissions? application or delegate?

    I am trying to do the same thing, but I ended up seeing below errors. for some reasons, I face MSA accounts error. please refer more info on - https://learn.microsoft.com/en-us/answers/questions/870631/change-notifications-giving-error-34subscription-v.html

    206953-image.png

    Was this answer helpful?


  4. Slobodan 11 Reputation points
    2022-05-09T16:36:01.17+00:00

    Experiencing the same issues create-subscriptions-403-for-mailreadbasic-applica.html

    With Mail.Read application permission subscriptions work, but with Mail.ReadBasic or Mail.ReadBasic.All (tried both even) it doesn't

    Was this answer helpful?

    0 comments No comments

  5. CarlZhao-MSFT 46,456 Reputation points
    2022-03-11T09:18:50.6+00:00

    Hi @HacheJulio

    This is an error caused by lack of permissions, use https://jwt.ms/ to parse your token, make sure you have the Mail.ReadBasic or Mail.ReadBasic.All application permission in your token.

    182149-image.png


    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.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.