Client Credentials Grant is not working

Hi Experts, I’m now trying to call /token endpoint with grant_type=client_credentials, and I’m getting the error here.

curl --location --request POST ‘https://dev-942705-admin.okta.com/oauth2/default/v1/token?grant_type=client_credentials&redirect_uri=http://localhost:3000&scope=customScope
–header ‘Accept: application/json’
–header ‘Authorization: Basic MG9ha2E1aGU4R2R0UG92a2w0eDY6UWFleU54OFpHUWRJdGo1cVAzUjhQTkkwdFNEVlZWaWhtRkoyaEZBRw==’
–header ‘Content-Type: application/x-www-form-urlencoded’
–header ‘Cookie: t=default; DT=DI0We-6hDOUT-esnzwnDr8MEA; JSESSIONID=303BB9B1FFCB2D589AB69AAC2E4A9C44’

<link
	href="https://ok11static.oktacdn.com/assets/img/icons/favicons/favicon-16x16.c55b69ae49b08edc7c000d12b8e5483f.png"
	rel="icon" type="image/png" sizes="16x16" />
<link
	href="https://ok11static.oktacdn.com/assets/img/icons/favicons/favicon-32x32.99bc356b6e293b927f9e3a2b69761c26.png"
	rel="icon" type="image/png" sizes="32x32" />
<link
	href="https://ok11static.oktacdn.com/assets/img/icons/favicons/favicon-96x96.de98828614fa33ca04fcfaa07679f345.png"
	rel="icon" type="image/png" sizes="96x96" />
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/img/icons/favicons/ms-icon-144x144.png">
<meta name="application-name" content="Okta" />
<meta name="theme-color" content="#ffffff">
<meta name="msapplication-config" content="/img/icons/favicons/browserconfig.xml" />

<title>
	Akamai Technologies-dev-942705 - Page Not Found</title>
<link href="https://ok11static.oktacdn.com/assets/css/saasure-min.ebd6cbe04743a3b7641a947796d6f790.css"
	type="text/css" rel="stylesheet" />
<link href="https://ok11static.oktacdn.com/assets/css/courage/courage.c2062876d736970e189f96a66089d965.css"
	type="text/css" rel="stylesheet" />
<link href="https://ok11static.oktacdn.com/assets/css/admin-overrides.3f77ea681465395221c11f3f405444aa.css"
	type="text/css" rel="stylesheet" />
<link href="https://ok11static.oktacdn.com/assets/css/sections/errors.b2abd427f382d7a7c6648d7d71a06a7f.css"
	type="text/css" rel="stylesheet" />
<!--[if IE]><link href="https://ok11static.oktacdn.com/assets/css/ie/ie.67af4e98a9276b3eedc54211bb17ace8.css" type="text/css" rel="stylesheet"/><![endif]-->
<!--[if gte IE 9]><link href="https://ok11static.oktacdn.com/assets/css/ie/ie9.e98bfbcf44b614a6d63c04328b8b7b5e.css" type="text/css" rel="stylesheet"/><![endif]-->

<script>
	if (typeof module === 'object') {window.module = module; module = undefined;}
</script>

<script>
	var okta = {
    migrateMute: true,
    locale: 'en',
    debug: false,
    deployEnv: '',
    userId: '',
    settings: {
        orgId: '',
        orgName: '',
        serverStatus: 'ACTIVE',
        persona: '',
        isDeveloperConsole: '' === 'true',
        isPreview: 'false' === 'true',
        permissions: []
    },
    logHasFeatureError: function(message) {
        var xhr = new XMLHttpRequest();
        xhr.open('POST', '/api/internal/client-logging/has-feature-error', true);
        xhr.setRequestHeader('Content-Type', 'application/json');
        xhr.send(JSON.stringify({
          message: message
        }));
    }

};
</script>
<script>
	window._features = window._features || [];
  _features.push('DEV_CONSOLE');
</script>
<script>
	window.okta || (window.okta = {}); okta.cdnUrlHostname = "//ok11static.oktacdn.com"; okta.cdnPerformCheck = false;
</script>
<script>
	window.okta || (window.okta = {});window.okta.mixpanel = false;
</script>
<script>
	if (window) { window.__OKTA_EXPORT_JQUERY__ = true; }
</script>

<script
	src="https://ok11static.oktacdn.com/assets/js/mvc/dll-common/dll.common.pack.270d8fd77f85dfd8d6a0f09748807f78.js"
	crossorigin="anonymous" integrity="sha384-EKR3z0s+nzOrglLBsvJ1X4kRVvJ6UmNyiDpYqMDZ/YV6l2lAFRGcQ/ll2Dm94D4j"
	type="text/javascript"></script>
<script
	src="https://ok11static.oktacdn.com/assets/js/mvc/init-dll/main-init-dll.pack.40b602e77aa81c6e4824ee0d881edd3c.js"
	crossorigin="anonymous" integrity="sha384-vyLW6Bx7CSO60lXvtriJdOzEZcUgh+l5TLYEkYFo98av5UWOrBfTY+sFvkepcVho"
	type="text/javascript"></script>
<script src="https://ok11static.oktacdn.com/assets/js/saasure.nojquery.min.08923fed3437ca1b6502f78ff355cbc6.js"
	crossorigin="anonymous" integrity="sha384-CmpFuGC4aZQjhLA1mDUAgopyN37/d9I18agBQhm0gRkxWhUGUIXuLra2u7jP4spz"
	type="text/javascript"></script>
<!--[if lt IE 9]><script src="https://ok11static.oktacdn.com/assets/enduser/js/vendor/css3-mediaqueries.fa295f0132f5335f352071ca3613a94a.js" crossorigin="anonymous" integrity="sha384-7pU2GSgyec3nzQMUNSuzanfJelP9UCOyHil0bOv+WnPKSS9lNA/tcxPyr7NV2w6c" type="text/javascript"></script><![endif]-->

<script>
	if (window.module) module = window.module;
</script>

Javascript is disabled on your browser.

Please enable Javascript and refresh this page to use Okta.

<div id="container">
	<iframe id="download-iframe" style="display: none;">
		<p>Your browser does not support iFrames</p>
	</iframe>
	<span class="hide" id="_xsrfToken">null</span>
	<script>
		function trackAdminHelpEvent() {
    // Check if OktaMetrics has been initialized and has component,
    // then tracks the click of global help link in top right of page for appropriate section
    if (typeof OktaMetrics !== "undefined" && OktaMetrics.component) {
        OktaMetrics.track('Help');
    }
}
	</script>

	<div id="header" class="clearfix">
		<div class="primary-nav clearfix">
			<div class="container primary-nav-wrap">
				<div class="logo clearfix">
					<a class="okta-main-logo-link"
						href="/admin/dashboard"><span class="icon oktamainlogo"></span></a>
				</div>

			</div>
		</div>

	</div>

	<!--[if gte IE 8]>

<![if lte IE 9]>

<style>
.unsupported-browser-banner-wrap {
  padding: 20px;
  border: 1px solid #ddd;
  background-color: #f3fbff;
}
.unsupported-browser-banner-inner {
  position: relative;
  width: 735px;
  margin: 0 auto;
  text-align: left;
}
.unsupported-browser-banner-inner .icon {
  vertical-align: text-bottom;
  margin-right: 5px;
  display: inline-block;
  position: static !important;
}
.unsupported-browser-banner-inner a {
  text-decoration: underline;
}
</style>

<div class="unsupported-browser-banner-wrap">
  <div class="unsupported-browser-banner-inner">
    <span class="icon icon-16 icon-only warning-16-yellow"></span>You are using an unsupported browser. For the best experience, update to <a href="https://support.okta.com/help/articles/Knowledge_Article/24532952-Platforms---Browser-and-OS-Support">a supported browser</a>.</div>
</div>

<![endif]>
<![endif]–>



404
		<div class="error-wrap clearfix">
			<div class="error">
				<img src="https://ok11static.oktacdn.com/assets/img/ui/http-error-404.e21dc7337e238d67a501b4bd3d3c1f42.png" width="340" height="145" alt="404: Page Not Found"/>
				<p class="error-title">Page Not Found</p>
			</div>
			<div class="error-content">
				<h1>We couldn't find the page you were looking for.</h1>
				<div class="nav-button-bar">
					<a class="nav-button button-primary" href="/">Go to Homepage</a>
				</div>
			</div>
		</div>

		<span class="hide" id="st-app">NONE</span>

https://developer.okta.com/docs/guides/implement-client-creds/use-flow/

I just wanted to know if I’m missing something - any comments would be appreciated.

Can you try without passing the cookie in the request header?

it should be without -admin in request URL

1 Like