Auth0 react working on localhost and not in dev environment

Hello I have a problem trying to use auth0 on the dev domain, I quadruple check the callback URL and its fine the problem I notice on the logs that the Authorization Code for Access Token is not happening and i get the error https://dev.wololoci.com/admin?error=invalid_request&error_description=StatusCode%3A%20401&state=cGZwUWxKaklpTHN3U3Jjfi1QTmlJbHEtU2ZPLkZLSi5%2BR2VNWFhNaTdCSQ%3D%3D

Hi @jdelannoy
Sounds as if https://dev.wololoci.com/admin is the callback URL, right?

If so, the error that the app is receiving in the callback (ā€œStatusCode 401ā€) seems to be coming from a rule or a custom DB script.

Can you check the rules for one maybe doing an external HTTP request thatā€™s ending in a 401? Try disabling rules one by one to see if the error disappears. If you have a custom DB, also check the script to make sure itā€™s working.

In the script of the gitlab integration i allways get the error of ā€œerrorā€: ā€œinvalid_requestā€
here is the script, if i make the request with postman with the access_token its worksā€¦
function(access_token, ctx, callback) {
request.get(ā€˜https://gitlab.com/api/v4/userā€™, {
ā€˜headersā€™: {
ā€˜Authorizationā€™: 'Bearer ā€™ + access_token,
}
}, function(err, resp, body) {

if (err) {
  return callback('err ' + err);
  return;
}

if (resp.statusCode !== 200) {
  return callback(new Error('StatusCode:' + resp.statusCode));
}


return callback(JSON.parse(body));

});
}

Can you try this instead? (putting the URL together with the headers in one options object):

var a = function(access_token, ctx, callback) {
  request.get(
    {
      url: "https://gitlab.com/api/v4/user",
      headers: {
        Authorization: "Bearer " + access_token
      }
    },
    function(err, resp, body) {
      if (err) {
        return callback("err " + err);
        return;
      }

      if (resp.statusCode !== 200) {
        return callback(new Error("StatusCode:" + resp.statusCode));
      }

      return callback(JSON.parse(body));
    }
  );
};

These script doesnā€™t work neither

if a use this script:

function(access_token, ctx, callback) {
request.get(ā€˜https://gitlab.com/api/v4/userā€™, {
ā€˜headersā€™: {
ā€˜Authorizationā€™: 'Bearer ā€™ + access_token,
}
}, function(err, resp, body) {

if (err) {
  return callback('err ' + err);
  return;
}

if (resp.statusCode !== 200) {
  return callback(new Error('StatusCode:' + resp.statusCode));
}

const u = JSON.parse(body);

const profile = {
  user_id: u.id,
  nickname: u.username,
  email: u.email,
  name: u.name,
  given_name: u.name,
  family_name: u.name,
  picture: u.avatar_url
};
return callback(null, profile);

});
}

{
ā€œstatusCodeā€: 403,
ā€œdataā€: ā€œ{"error":"invalid_grant","error_description":"Invalid authorization code"}ā€
}

but the user gets created anyway

So again, i got it working on localhost but when i deploy mi solution to my domain its stop working all the integrations with no errorsā€¦ the success exchange event is never happening

Ok so the problem was in the aws Amplify services with the redirect rules i have to delete all the rules and add
source
</[1]+$|.(?!(jsx|json|css|map|chunk.js|chunk.js.map|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>
Target address
/index.html
type
rewrite 200


  1. ^. ā†©ļøŽ

1 Like

Cool to see that you have it figured out!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.