I am trying to create an application where i want to fetch Outlook mails. I am using using simple OAuth 2.0 for the access token. I am successfully getting the code. When I am trying to get the access token in exchange of code I am getting 400 bad request error.
const tokenConfig = {
code: auth_code,
redirect_uri: redirectUri,
scope: scopes.join(' ')
};
try {
const result = await oauth2.authorizationCode.getToken(tokenConfig);
const accessToken = oauth2.accessToken.create(result);
} catch (error) {
console.log('Access Token Error', error.message);
}
Can you help what wrong I am doing. Please comment for more information.
For me the solution was to set
ModuleOptions.options.authorizationMethod
to'body'
:Edit [6/12/2023]: Here's a link to the API documentation for
simple-oauth2
. I've also copied the bits that pertain to this answer below:options
additional options to setup how the module perform requestsauthorizationMethod
- Method used to send the client.id/client.secret authorization params at the token request. Valid options areheader
orbody
. If set to body, the bodyFormat option will be used to format the credentials. Defaults to header