<?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 to generate and authorized java spring controller using JWT]]></title><description><![CDATA[<p dir="auto">I am a starter plan user and want to implement JWT using client credentials flow in my Java Spring Boot Application. I generated the license in the fusion auth portal and set up the auth docker instance. I am getting the below error when generating the JWT token using client_id and secret.</p>
<pre><code>{
    "error": "not_licensed",
    "error_description": "You must enter a valid license Id in order to use the Entity Management features of FusionAuth, which include the Client Credentials Grant.",
    "error_reason": "not_licensed"
}
</code></pre>
<p dir="auto">Please help me in forming the correct token generation call and then use the same token to authorize my controller.</p>
<pre><code>curl --location --request POST 'http://&lt;base_url&gt;:9011/oauth2/token?grant_type=client_credentials&amp;client_id=&lt;&gt;&amp;client_secret=&lt;&gt;&amp;redirect_uri=&lt;url&gt;' \
--data ''
</code></pre>
]]></description><link>https://fusionauth.io/community/forum/topic/2456/how-to-generate-and-authorized-java-spring-controller-using-jwt</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 00:17:18 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/2456.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Jul 2023 19:11:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to generate and authorized java spring controller using JWT on Fri, 04 Aug 2023 18:19:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/2561">@shyamsundar-k</a> said in <a href="/community/forum/post/6388">How to generate and authorized java spring controller using JWT</a>:</p>
<blockquote>
<p dir="auto">We need to pass the token in the API header as Authorization: Bearer&lt;token&gt; But what is the process so that I can validate the endpoint with the valid token if the token is invalid or does not have the required roles or scope then I should get 401 else I should be able to access the API successfully.</p>
</blockquote>
<p dir="auto">Once you have a token in your API, you can validate it in two different ways. But it's worth noting that to validate the token, you must validate the signature and then the claims.</p>
<p dir="auto">First option: use a library to validate the signature. Most languages have options. For java, <a href="https://github.com/fusionauth/fusionauth-jwt#verify-and-decode-a-jwt-using-rsa" rel="nofollow ugc">you can use fusionauth-jwt, the readme has sample code</a>.</p>
<p dir="auto">Second option: <a href="https://fusionauth.io/docs/v1/tech/apis/jwt#validate-a-jwt" rel="nofollow ugc">use the validate API</a>. You could use the <a href="https://github.com/FusionAuth/fusionauth-java-client/blob/master/src/main/java/io/fusionauth/client/FusionAuthClient.java#L5399" rel="nofollow ugc">FusionAuth client library</a> to make this call if you'd like.</p>
<p dir="auto">The first means you have to pick a library. The second means you have to make a network call.</p>
<p dir="auto">Either way, after you validate the signature, you need to check the claims (issuer, audience, expiration, custom claims) to make sure they are what you expect.</p>
<p dir="auto">Here's more about how to <a href="https://fusionauth.io/articles/tokens/building-a-secure-jwt#consuming-a-jwt" rel="nofollow ugc">consume a JWT</a>.</p>
]]></description><link>https://fusionauth.io/community/forum/post/6405</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/6405</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Fri, 04 Aug 2023 18:19:07 GMT</pubDate></item><item><title><![CDATA[Reply to How to generate and authorized java spring controller using JWT on Tue, 01 Aug 2023 20:13:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/20">@dan</a> I have a Java Rest API. How to authenticate the APIs using generated tokens? What are the steps?</p>
<p dir="auto">We need to pass the token in the API header as Authorization: Bearer&lt;token&gt; But what is the process so that I can validate the endpoint with the valid token if the token is invalid or does not have the required roles or scope then I should get 401 else I should be able to access the API successfully.</p>
]]></description><link>https://fusionauth.io/community/forum/post/6388</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/6388</guid><dc:creator><![CDATA[shyamsundar.k]]></dc:creator><pubDate>Tue, 01 Aug 2023 20:13:33 GMT</pubDate></item><item><title><![CDATA[Reply to How to generate and authorized java spring controller using JWT on Tue, 01 Aug 2023 20:09:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/20">@dan</a> Thanks. I am able to add the license now.</p>
]]></description><link>https://fusionauth.io/community/forum/post/6387</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/6387</guid><dc:creator><![CDATA[shyamsundar.k]]></dc:creator><pubDate>Tue, 01 Aug 2023 20:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to How to generate and authorized java spring controller using JWT on Tue, 01 Aug 2023 14:08:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/2561">@shyamsundar-k</a></p>
<p dir="auto">It looks like you haven't entered the license Id on your instance. You can do so by following the steps outlined here:</p>
<p dir="auto"><a href="https://fusionauth.io/docs/v1/tech/admin-guide/licensing" rel="nofollow ugc">https://fusionauth.io/docs/v1/tech/admin-guide/licensing</a></p>
]]></description><link>https://fusionauth.io/community/forum/post/6378</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/6378</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Tue, 01 Aug 2023 14:08:29 GMT</pubDate></item></channel></rss>