Support Questions
Find answers, ask questions, and share your expertise

Curl command for CM login

Curl command for CM login

New Contributor

Hi Team ,

 

I trying to get information using curl command and seems CM Manager sending me login page. I  already using user name and password .

 

curl -X GET --user 'xxxx':'xxxx' https://CM URL:7183/cmf/serviceRedirect/schemaregistry/instances
<!-- __CLOUDERA__PRE__LOGIN__FORM__ -->

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<body></body>
</html>
<script type="text/javascript">
var returnUrl = window.location.pathname + window.location.search + window.location.hash;
var loginPageUrl = "/cmf/login";
if (returnUrl !== "/cmf" && returnUrl !== "/cmf/" && returnUrl !== "/cmf/home" && returnUrl !== "/cmf/home/") {
loginPageUrl = loginPageUrl + "?returnUrl=" + encodeURIComponent(returnUrl);
}
window.location = loginPageUrl;
</script>

 

 

pls some one help.

 

Thanks

3 REPLIES 3

Re: Curl command for CM login

Expert Contributor

Hello

 

One example

 

$ curl -X GET -u "admin:admin" -i http://cm-host:7180/api/v6/tools/echo?message=hello

 

  • The -X GET sends a GET request, which is the default and can be omitted. You would use PUT, POST and DELETE for other usage scenarios.
  • The -u "admin:admin" authenticates with CM using HTTP basic auth. admin:admin is the CM default user account.
  • The -i tells curl to include HTTP headers in the output, which is useful for debugging.

Re: Curl command for CM login

New Contributor

getting below error 

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 401 Bad credentials</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /api/v6/tools/echo. Reason:
<pre> Bad credentials</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.14.v20181114</a><hr/>

</body>
</html>

Re: Curl command for CM login

New Contributor

user name and url mark as xxx

curl -X GET --user 'xxxx':'xxxx' -i https://CMURL:7183/cmf/serviceRedirect/schemaregistry/instances
HTTP/1.1 200 Connection established

HTTP/1.1 200 OK
Date: Mon, 12 Apr 2021 06:47:14 GMT
Set-Cookie: CLOUDERA_MANAGER_SESSIONID=node0xzy9bnjzrx6x1s70qz8gu8w2713126907.node0;Path=/;Secure;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Language: en-AU
Content-Type: text/html;charset=utf-8
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Expires: Tue, 01 Jan 1980 1:00:00 GMT
X-UA-Compatible: IE=edge
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Length: 546
Server: Jetty(9.4.14.v20181114)

<!-- __CLOUDERA__PRE__LOGIN__FORM__ -->

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<body></body>
</html>
<script type="text/javascript">
var returnUrl = window.location.pathname + window.location.search + window.location.hash;
var loginPageUrl = "/cmf/login";
if (returnUrl !== "/cmf" && returnUrl !== "/cmf/" && returnUrl !== "/cmf/home" && returnUrl !== "/cmf/home/") {
loginPageUrl = loginPageUrl + "?returnUrl=" + encodeURIComponent(returnUrl);
}
window.location = loginPageUrl;
</script>