Can we get browsers user-agent?

We are trying to get access to a brower’s user-agent when they sign up. We expected to see it on context.webtask.headers[“user-agent”]. What we get when we dump the context object is “User-Agent”:“webtask/backchannel”.

Is there any way to get the user-agent value from the user’s browser?

Hi @scott8,

Are you wanting the userAgent data from within a rule? If so you can access it with context.request.userAgent.



Hi Stephanie - we need this on a hook. Specifically the pre-user registration. It is our understanding that rules are not invoked during signup?

Unfortunately, I don’t believe the user-agent is available for the pre-registration hook. The webhook headers contain this data when a user signs up:

    "host": "",
    "accept-encoding": "gzip",
    "authorization": "Bearer 44827...9e96",
    "content-type": "application/json",
    "ot-baggage-auth0-request-id": "61749a308fe3ec1d",
    "ot-tracer-sampled": "true",
    "ot-tracer-spanid": "32a...13f3",
    "ot-tracer-traceid": "37c6...b5d9",
    "request-timeout": "20000",
    "x-amzn-trace-id": "Root=1-60...8e6fe",
    "x-real-ip": "",
    "x-wt-runtime": "node12",
    "x-forwarded-for": "[IP list]",
    "x-forwarded-port": "443,8721",
    "x-forwarded-proto": "https,https",
    "content-length": "368",
    "accept-version": "0.0.0",
    "x-wt-token": "eyJhbGciOiJIUzI1NiIsImtpZ...NXoWtc6uxR4eJutcM",
    "x-wt-params": "eyJjb2RlX2l...VudCJ9",
    "connection": "close"

And the context object only contains:

@param {object} context - Auth0 connection and other context info
@param {string} context.renderlanguage - language used by signup flow
@param {string} context.request.ip - ip address
@param {string} context.request.language - language of the client agent
@param {object} context.connection - information about the Auth0 connection
@param {object} - connection id
@param {object} - connection name
@param {object} context.connection.tenant - connection tenant
@param {object} context.webtask - webtask context

You can use a rule’s context object to only run the rule after a user signs up like so:

function (user, context, callback) {
  // Only run this rule when user signs up
  var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
  if (count > 1) {
    return callback(null, user, context);

  var userAgent = context.request.userAgent;
  // throw an error for a particular browser
  if (userAgent.includes('Mozilla')) {
    return callback(new UnauthorizedError('Access denied for browser: ' + userAgent));
  callback(null, user, context);

In this example, the user would be created, but they would not be able to access the application upon signing up if they were using a particular browser.

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