<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D5WR00001CZ0910ADOkta Identity EngineWorkflowsAnswered2026-01-30T17:08:31.000Z2026-01-23T04:55:35.000Z2026-01-30T17:08:31.000Z
400 bad request for JWT Bearer Token flow for machine to machine authentication

Hi,

I am trying to test the machine to machine okta authentication for a backend service.I created a service app using Okta inegrator account for the REST API endpoint that I need to authenticate with Okta.I chose Public /Private key for client authentication and generated the public/private keys.Now when am, testing the flow by writing a standalone springboot web app and calling the /token endpoint am getting 400 bad request invalid client.I have verified the signed JWT by decoding the JWT and everything looks good.I have added the default access policy as well in okta admin console and selected this service app under assigned to clients but still does not work.Any inputs or suggestions please to make this work?The KID,client ID,sub and aud everything looks good.Not sure where am going wrong.Please help.

 

I am using Spring Rest Template to make the http POST call to /token endpoint to get the access token.

 

RestTemplate restTemplate = new RestTemplate();

 

HttpHeaders headers = new HttpHeaders();

headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

 

MultiValueMap<String, String> body = new LinkedMultiValueMap<>();

body.add("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer");

body.add("assertion", assertion);

body.add("scope", "openid");..My Token URL is https://integrator-5048514.okta.com/oauth2/default/v1/token

 

 


Loading
400 bad request for JWT Bearer Token flow for machine to machine authentication