0

When trying to use the adal-node library from here for the Server to Server via Client Credentials, the code works for the discovery endpoint etc., but when trying to use it with Office 365, I get the "Unsupported app only token" error.

I'm wondering if I need to load a certificate into Azure AD, but not sure how to then use that from my node script.

Any pointers in the right direction or thoughts on whether or not that is the issue greatly appreciated.

Many thanks in advance. D.

Darren
  • 1,071
  • 1
  • 15
  • 39

1 Answers1

0

As Office 365 unified API has been integrated into Microsoft Graph, so we can get the server to server access token for Office 365 APIs, reference to Call Microsoft Graph in a service or daemon app.

If you are using the azure-activedirectory-library-for-nodejs for the access token, we need do some modifications in this sample:

if (!parametersFile) {
  sampleParameters = {
    tenant : '<tenant_id>',
    authorityHostUrl : 'https://login.microsoftonline.com',
    clientId : '<AD_application_client_id>',
    clientSecret : '<client_secret_key>'
  };
}

var authorityUrl = sampleParameters.authorityHostUrl + '/' + sampleParameters.tenant;

// var resource = '00000002-0000-0000-c000-000000000000';
var resource = 'https://graph.microsoft.com/';
Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • Thanks. Yes, access to the graph api seems to work, but I don't think this provides me with access to sharepoint lists for example? – Darren Feb 02 '16 at 09:57
  • When I specify the resource as the graph api and try and use the https://tenantid.sharepoint.com/_api/web endpoint, it complains of an 'invalid audience'. If I change the resource to that for sharepoint (i.e. https://tenantid.sharepoint.com/) I get the 'unsupported app only token' error. – Darren Feb 02 '16 at 10:05
  • It seems that your scenario is similar to the case 2 under the Identify the set of trust relationships section at https://technet.microsoft.com/en-us/library/jj219546.aspx, which may help you. – Gary Liu Feb 03 '16 at 05:57