NevC Posted March 21 Share Posted March 21 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 More sharing options...
Stuart Silvester Posted March 21 Share Posted March 21 A 403 in your case is likely happening at the edge of the network -- the request never reaches the Community so it cannot be logged. It's worth checking that you're sending a user-agent with the request, if this is missing it can cause some firewalls to block requests. Link to comment Share on other sites More sharing options...
NevC Posted March 21 Author Share Posted March 21 Thanks for your reply Stuart. Yes we are sending 'User-Agent': 'auth0-action-populate-forum-user-data' Link to comment Share on other sites More sharing options...
NevC Posted March 23 Author Share Posted March 23 @Stuart Silvester Kindly let us know when you have updates regarding the above please. Thanks. Link to comment Share on other sites More sharing options...
NevC Posted March 24 Author Share Posted March 24 @Stuart Silvester kindly note that this issue is high priority for since a number of users cannot log into forum because of this. Any updates please? Link to comment Share on other sites More sharing options...
Marc Stridgen Posted March 24 Share Posted March 24 I have created a ticket for you on this, so we can take a closer look for you NevC 1 Link to comment Share on other sites More sharing options...
NevC Posted March 24 Author Share Posted March 24 Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts