I'm integrating outlook api into my app with microsoft graph but it keeps returning my this error instead of giving any error. However, when i do mess up the config it tells me that my config is inavlid.
the function im using to get microsoft graph
async msalSendEmail(
data: {
from: string;
toRecipients: [{ emailAddress: { address: string } }];
subject: string;
headers?: [{ 'In-Reply-To': string }, { References: string }];
body: {
contentType: string;
content: string;
};
},
refreshToken: string,
) {
const cca = new ConfidentialClientApplication(this.msalConfig);
const response = await cca.acquireTokenByRefreshToken({
refreshToken,
scopes: [
'user.read',
'user.read.all',
'user.readbasic.all',
'mail.read',
'mail.readbasic',
'mail.readwrite',
'mail.send',
],
});
const credential = new ClientSecretCredential(
this.msalConfig.auth.tenantId,
this.msalConfig.auth.clientId,
this.msalConfig.auth.clientSecret,
);
const authProvider = new TokenCredentialAuthenticationProvider(credential, {
scopes: ['https://graph.microsoft.com/.default'],
});
const client = Client.initWithMiddleware({
defaultVersion: 'v1.0',
debugLogging: true,
authProvider,
});
const message = {
subject: data.subject,
body: {
contentType: 'Text',
content: data.body.content,
},
toRecipients: [
{
emailAddress: {
address: '[email protected]',
},
},
],
};
Things i tried to solve this issue:
- Went from Delegate Access to Application Access (doesn't work at all)
- Tried Public oAuth Method
- Tried Confidential oAuth Method
- Tried OnBehalfOf but that is not working as well
- Tried giving all the possible permission
- Created a pump for Readable Stream but that is returning undefined
Solved My solution was to replace the custom tenantid with common in the msal configuration.

