Make a POST to API server using accessToken, after a user has registered

I want to create a resource for the user when they first register. In order to do that I need the access token, of the newly created and logged in user.

I tried using Rules, but the accessToken is equal to an empty object after logging in for some reason.

function (user, context, callback) {
  console.log(user);
  console.log(context);
  
  if (context.stats.loginsCount === 1) {
    console.log("Creating example resource");
    
    const options = {
      method: 'POST',
      uri: "http://",
      headers: {
        "Authorization": "Bearer " + context.accessToken
      }
    };
    request(options, function(err, res) {
      console.log(res.body);
    });   
  }

  callback(null, user, context);
}

How do I send a POST after the user has logged in?

Did you ever happen to resolve this? I just opened a similar issue…

Thanks.

Did you guys ever get this to work? I’m stuck being unable to get an accessToken.

Hi there! 2020, still having this issue… Someone had managed to resolve it?