I've been attempting to make calls to the Azure Ad Graph API
from my typescript
code, but I keep encountering the "Unauthorized" error.
lavaNET.SharePointREST.getJsonWithoutSite(this, "https://graph.windows.net/lavanet.dk/users?api-version=1.6", (tmplData: any, tmplTextStatus: string, tmplXHR: JQueryXHR) => {
console.log(tmplData)
});
export function getJsonWithoutSite(context: any, url: string, success: SuccessCallback, failure?: ErrorCallback) {
$.ajax({
method: 'GET',
context: context,
headers: {
'Authorization': 'Bearer zc21eb27-760b-4b46-828e-xxxxxxxxxxxxx',
'Content-Type': 'application/x-www-form-urlencoded'
},
url: url,
dataType: 'json',
accepts: { json: 'application/json; odata=verbose' },
success: success,
error: failure || function (jqXHR, textStatus, errorThrown) { alert('Error: ' + errorThrown); }
});
}
Could someone please help me understand why I am unable to retrieve data from the Ad?
Update Do you think I am on the right track with this: https://i.sstatic.net/f3D0w.png
Update Responding to Gary Liu - MSFT
, these are the keys I am getting from his code: https://i.sstatic.net/mtw4G.png
Is my Ajax setup correct and which key should I be using?