Error Access to XMLHttpRequest at "http"rom origin has been blocked by CORS policy - Graph API -

Iron Contributor

Hi All,
I would like to retrieve list of recent files from a particular document library or site for the logged on user

This is using a content editor on a sharepoint classic site

When i run the code below i get error

Access to XMLHttpRequest at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Using the code below to get an access token and i get the error above

var token;  
$(document).ready(function () {  

function requestToken() {  
    var clientId = ""
    var clientSecret = ""
    var tenantID = ""
    var uri = ""+ tenantID + "/oauth2/v2.0/token"

        "async": true,  
        "crossDomain": true,  
        "url": "", // Pass your tenant 
        "method": "POST",  
        "headers": {  
            "content-type": "application/x-www-form-urlencoded"  
        "data": {  
            "grant_type": "client_credentials",  
            "client_id ": clientId, //Provide your app id      
            "client_secret": clientSecret, //Provide your secret      
            "scope ": "",
            "redirectUri" :  ""
        success: function (response) {  
            token = response.access_token;  
        error: function (error) {  


I have setup the app registrations and also added Redirect URIs for SPA and Web


Not sure what else I'm missing


Thanks in Advance

1 Reply