
prashanths.68473 (Customer) asked a question.
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

Hi @prashanths.68473 (Customer) , Thank you for reaching out to the Okta Community!
This question is more appropriate for our dedicated Okta Developer Forum.
My advice would be to reach out via devforum.okta.com to take advantage of their expertise.
While we'll do our best to answer all of your questions here, this medium is more inclined towards Okta core products and features (non-custom/developer work).
In the meantime, please review the following similar devforum posts that might offer some insight:
https://devforum.okta.com/t/recieing-400-bad-request-when-using-bearer-token-auth/25350
https://devforum.okta.com/t/bad-request-when-trying-to-get-access-token-using-jwt-token/18443
Regards.
--
Help others in the community by liking or hitting Select as Best if this response helped you.
Collect them all. Learn a new skill and earn a new Okta Learning badge.
Just released: More Okta Community badges just added