# Okta access token using token endpoint url returns http 401 error

**URL:** <https://devforum.okta.com/t/okta-access-token-using-token-endpoint-url-returns-http-401-error/18033>\
**Category:** Questions\
**Tags:** java\
**Created:** [November 13, 2021, 2:39am UTC](https://devforum.okta.com/t/okta-access-token-using-token-endpoint-url-returns-http-401-error/18033 "2021-11-13T02:39:00Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![aaronpk](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/aaronpk/32/1737_2.png) [@aaronpk](https://devforum.okta.com/u/aaronpk)\
**Post date:** [November 13, 2021, 4:41am UTC](https://devforum.okta.com/t/okta-access-token-using-token-endpoint-url-returns-http-401-error/18033/4 "2021-11-13T04:41:22Z")

</div>

Got it, the `oktaUrl` looks like the first line I can see in the paste.

The error is accurate, you can only send the client id and secret in _either_ the post body or the HTTP header, so you’ll either need to remove the client\_id and client\_secret from the post body parameters or remove the Authorization header.

Also you’ll want to properly form-encode the post body parameters. I’d recommend using an HTTP client that has that built in rather than building the post body by hand.

---

_[View the full topic](https://devforum.okta.com/t/okta-access-token-using-token-endpoint-url-returns-http-401-error/18033)._
