I am using a registered app to create/modify/upload folders and files one one drive business account through Graph API. I have everything set up and working when copying the AuthToken from Graph Explorer directly into my code. When I create the token in my code myself and I run my queries with my generated token I receive a Response Code 404 Not found. I will include my permissions below. Any help would be great, thank you!
const APP_ID ='xxxxxx';
const APP_SECERET = 'xxxxxx'
const TOKEN_ENDPOINT ='https://login.microsoftonline.com/b1a8639c-5c80-4ded-9347-d937b05848cb/oauth2/v2.0/token';
const MS_GRAPH_SCOPE = 'https://graph.microsoft.com/.default';
const postData = {
client_id: APP_ID,
scope: MS_GRAPH_SCOPE,
client_secret: APP_SECERET,
grant_type: 'client_credentials'
};
axios.defaults.headers.post['Content-Type'] =
'application/x-www-form-urlencoded';
let token = '';
function getToken () {
return new Promise((resolve, reject) => {
axios
.post(TOKEN_ENDPOINT, qs.stringify(postData))
.then(response => {
var access_token = response.data.access_token;
resolve();
console.log(access_token)
})
.catch(error => {
console.log(error);
});
}).catch(err => console.log(err))
}
// getToken()
oneDriveAPI.items.createFolder({
accessToken: accessToken,
rootItemId: "root",
name: "ssss"
}).then((item) => {
console.log(item)[enter image description here][1]
}).catch( (err) => {
console.log(err);
})