<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How can I get entity permissions into a JWT?]]></title><description><![CDATA[<p dir="auto">I have set up some Entities and permissions. I'd like to return those permission in the JWT.  How can I accomplish this?</p>
]]></description><link>https://fusionauth.io/community/forum/topic/2500/how-can-i-get-entity-permissions-into-a-jwt</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 09:00:50 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/2500.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 15 Sep 2023 14:21:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can I get entity permissions into a JWT? on Fri, 15 Sep 2023 14:30:54 GMT]]></title><description><![CDATA[<p dir="auto">This can be accomplished through using <a href="https://fusionauth.io/docs/v1/tech/lambdas/" rel="nofollow ugc">lambdas</a>.  You will want to create a lambda of type <code>JWT Populate</code>.  The code will look something like this.</p>
<pre><code>function populate(jwt, user, registration) {

  var urlToFetch = "http://localhost:9012/api/entity/grant/search?userId=" + user.id;

  var response = fetch(urlToFetch, {
    method: "GET",
    headers: {
      "Content-Type" : "application/json",
      "Authorization" : "this_really_should_be_a_long_random_alphanumeric_value_but_this_still_works"
    }
  });
  
  if (response.status === 200) {
    jwt.entityInfo = JSON.parse(response.body);
  } else {
    console.error("Error: " + response.status + " " + response.statusText);
  } 
  
}
</code></pre>
<p dir="auto">The go to your application in the admin UI and under the <code>JWT</code> tab, under the <strong>Lambda settings</strong> section assign that lambda to the 'Access Token populate lambda'</p>
<p dir="auto">A few things to keep in mind:</p>
<ul>
<li>Please note the use of port <code>9012</code> when calling the API from the lambda.  From the documentation <em>"Use port 9012, or the configured value for fusionauth-app.http-local.port, whenever making a FusionAuth API call in a lambda. Doing so minimizes network traffic contention and improves performance."</em></li>
<li>As of this post, you will need the Essentials license for the HTTP Lambda Connect feature.</li>
</ul>
]]></description><link>https://fusionauth.io/community/forum/post/6556</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/6556</guid><dc:creator><![CDATA[mark.robustelli]]></dc:creator><pubDate>Fri, 15 Sep 2023 14:30:54 GMT</pubDate></item></channel></rss>