Jump to content

Forum REST API logs not showing HTTP Status 403 errors


Recommended Posts

Hi Developer Team,

On our production forum user login, we have an Auth0 post login flow to get user details from Forum through the GET core/members. This is the code for the Populate forum user data on login:

* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
const axios = require("axios");
exports.onExecutePostLogin = async (event, api) => {
const namespace = '<CG API URL>';
const forumURL = 'https://forum.casinogrounds.com';
api.accessToken.setCustomClaim(`${namespace}/avatar`, event.user.picture);
api.accessToken.setCustomClaim(`${namespace}/email`, event.user.email);
api.accessToken.setCustomClaim(`${namespace}/username`, event.user.username);
 
const url = `${forumURL}/api/core/members?key=${event.secrets.forumApiKey}&email=${encodeURIComponent(event.user.email)}`;
// console.log('url: ', url);
const forumUserData = await axios.get(url, {
headers: {
'User-Agent': 'auth0-action-populate-forum-user-data',
}
});
 
if (forumUserData.status === 200 && forumUserData.data.results && forumUserData.data.results.length > 0 && forumUserData.data.results[0].email === event.user.email) {
api.accessToken.setCustomClaim(`${namespace}/forum_user_profile_url`, forumUserData.data.results[0].profileUrl);
api.accessToken.setCustomClaim(`${namespace}/forum_user_photo_url`, forumUserData.data.results[0].photoUrl);
api.accessToken.setCustomClaim(`${namespace}/forum_user_name`, forumUserData.data.results[0].name);
}
};

From Auth0, we are receiving a 403 status error from Forum but on the REST API logs I am only seeing 200, 201 and 404 errors. The error from Auth0 is the following: 

{
   "action_name":"Populate forum user data on login",
   "response":{
      "error":{
         "code":"ERR_BAD_REQUEST",
         "message":"Request failed with status code 403",
         "name":"AxiosError",
         "stack":"AxiosError: Request failed with status code 403\n    at settle (/data/layers/layers-zfDn/zfDngH1yU51TNG8pkEdFfEpUsA11xFgdd1aUUCXYbl8/node_modules/axios/dist/node/axios.cjs:1900:12)\n    at IncomingMessage.handleStreamEnd (/data/layers/layers-zfDn/zfDngH1yU51TNG8pkEdFfEpUsA11xFgdd1aUUCXYbl8/node_modules/axios/dist/node/axios.cjs:2952:11)\n    at IncomingMessage.emit (node:events:539:35)\n    at IncomingMessage.emit (node:domain:537:15)\n    at endReadableNT (node:internal/streams/readable:1345:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)"
      },
      "stats":{
         "total_request_duration_ms":102,
         "total_runtime_execution_duration_ms":99,
         "runtime_processing_duration_ms":5,
         "action_duration_ms":94,
         "boot_duration_ms":5,
         "network_duration_ms":3
      }
   },
   "error":{
      "id":"invalid_argument",
      "msg":"Invalid Argument"
   },
   "started_at":"2023-03-19T14:39:38.639568081Z",
   "ended_at":"2023-03-19T14:39:38.742165298Z"
}
 
 

In the above the key is the following 

   "error":{
      "id":"invalid_argument",
      "msg":"Invalid Argument"
   },

But since the status is 403 not 400, kindly could you please let us know what is missing or not done correctly please?

Thanks and regards,

Neville Camilleri

Casinogrounds

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...