0

I have been trying for weeks to add a new Schema Extension for my Microsoft Graph based MVC application, essentially to store some basic variables along with a mail Message.

I've followed this example from GitHub and after some very frustrating days of working out that "Boolean" & "Integer" weren't supported property types, I then ran into the fabled "Insufficient privileges to complete the operation"...

I have been pulling my hair out trying to work out how and where I'm supposed to add my new extension, as it stands I'm trying to add it with the below code as an authenticated user (who is an admin):

SchemaExtension extensionPayload = new SchemaExtension()
{
    Description = "my extension example",
    Id = $"myExtensionExample",
    Properties = new List<ExtensionSchemaProperty>()
    {
      new ExtensionSchemaProperty() { Name = "prop1", Type = "String" },
      new ExtensionSchemaProperty() { Name = "prop2", Type = "String" }
    },
    TargetTypes = new List<string>()
    {
      "Message"
    }
};

SchemaExtension test = await client
    .SchemaExtensions
    .Request()
    .AddAsync(extensionPayload);

My Graph Client is generated with the below code:

public static async Task<GraphServiceClient> GetClient(HttpContextBase context)
{
    string token = await GetAccessToken(context);

    GraphServiceClient client = new GraphServiceClient(
        new DelegateAuthenticationProvider(
            (requestMessage) =>
            {
                requestMessage.Headers.Authorization =
                    new AuthenticationHeaderValue("Bearer", token);

                return Task.FromResult(0);
            }
        )
    );

    return client;
}

And my Oauth config requests the following permissions:

<add key="ida:AppScopes" value="User.Read Mail.ReadWrite Mail.Send Contacts.ReadWrite Directory.AccessAsUser.All" />

I've checked the Azure App Permissions of the account I'm testing with and they all appear to be correct? Is that where they're supposed to be??

ANY pointers would be greatly appreciated, as I've lost so much time trying to get what I thought was a very straight forward test app up and running.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
Shawno0
  • 1
  • 1
  • Please indent your code properly, that makes it easier to read. – jrswgtr Mar 21 '19 at 16:00
  • That is the best I could get it, copying from VS it will not format as code correctly if the indents are removed prior to copying, as I felt copying direct code was better for debugging than potentially introducing typos by re-typing. – Shawno0 Mar 21 '19 at 16:12
  • Then don't retype it but remove spaces – jrswgtr Mar 21 '19 at 16:37
  • Have you received Admin Consent for your app id on this tenant? – Marc LaFleur Mar 21 '19 at 19:07
  • Looking in Azure AD under apps my app shows as having all the required permissions, however the azure ad tenancy I'm using to test is not the same account the app is registered under. But I've not seen any documentation that says this would be a problem? – Shawno0 Mar 21 '19 at 22:09

1 Answers1

0

According to the docs, using this call with Application permissions isn't supported. Permissions table from MS Graph API docs