error getting access token

INAMALI PALASANIYA
0
Reputation points
we are trying to call outlook mail send API behalf of third-party user after they allow permission to us
so for this first we get code by api
import { PublicClientApplication } from "@azure/msal-node";
const config = {
auth: {
clientId: "8bf2efb9-d262-4092-bfbd-1a2f05789277",
redirectUri: "http://localhost:3000/setting",
clientSecret: secreatID,
authority: "https://login.microsoftonline.com/consumers", // Use the /consumers endpoint for personal Microsoft accounts
},
};
const pca = new PublicClientApplication(config);
//GET AUTH-URL-CODE
export async function getAuthUrlCode(res) {
const authCodeUrlParameters = {
scopes: ["https://graph.microsoft.com/.default"],
redirectUri: "http://localhost:3000/setting",
};
const authCodeUrl = await pca.getAuthCodeUrl(authCodeUrlParameters);
return authCodeUrl
};
will get code on redirected URL
after that will try to get accessToken by...
export async function getToken() {
const tokenRequest = {
code: code,
redirectUri: "http://localhost:3000/setting", // Must match the redirect URI configured in Azure AD app
scopes: ["https://graph.microsoft.com/.default"],
clientSecret: config.auth.clientSecret, // Include the client_secret parameter here
};
const response = await pca.acquireTokenByCode(tokenRequest);
console.log('------', response.accessToken);
return response.accessToken;
}
and will get error
{
"status": 400,
"message": "invalid_client: 70002 - [2023-10-16 09:45:07Z]: AADSTS70002: The provided request must include a 'client_secret' input parameter.\r\nTrace ID: 5854f7bd-b104-4796-995d-2fcd1af15801\r\nCorrelation ID: 59ec1fe6-9730-4b7e-a5e1-b053383639e8\r\nTimestamp: 2023-10-16 09:45:07Z - Correlation ID: 59ec1fe6-9730-4b7e-a5e1-b053383639e8 - Trace ID: 5854f7bd-b104-4796-995d-2fcd1af15801",
"result": {}
}
please help me out
Microsoft Security Microsoft Graph
13,721 questions
Microsoft Security Microsoft Entra Other
2,588 questions
1 answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more