<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Connecting to basic alfresco repository using CMIS in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126168#M34366</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to connect to the basic alfresco repository using the CMIS API URL using Atompub or browser binding.&lt;/P&gt;&lt;P&gt;I tried connecting to the repository using the URLs provided in the alfresco documentation.&lt;/P&gt;&lt;P&gt;URLs :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pln"&gt;http&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="com"&gt;//&amp;lt;hostname&amp;gt;:&amp;lt;port&amp;gt;/alfresco/api/-default-/public/cmis/versions/1.1/atom&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class="pln"&gt;http&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="com"&gt;//&amp;lt;hostname&amp;gt;:&amp;lt;port&amp;gt;/alfresco/api/-default-/public/cmis/versions/1.1/browser&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;But I am facing an error related to http authentication&lt;/P&gt;&lt;PRE&gt;{
    "status" : 
  {
    "code" : 401,
    "name" : "Unauthorized",
    "description" : "The request requires HTTP authentication."
  },  
  
  "message" : "11210005 Authentication failed for Web Script org\/alfresco\/api\/opencmis\/OpenCMIS.get",  
  "exception" : "",
  
  "callstack" : 
  [ 
  	   
  ],
  
  "server" : "Enterprise v6.2.0 (ra498a911-b5) schema 13,001",
  "time" : "21 Dec 2020, 07:33:37"
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;How can I solve this error, where do I need to auntheticate this?&lt;/P&gt;</description>
    <pubDate>Mon, 21 Dec 2020 07:46:06 GMT</pubDate>
    <dc:creator>Vishruti_Shah</dc:creator>
    <dc:date>2020-12-21T07:46:06Z</dc:date>
    <item>
      <title>Connecting to basic alfresco repository using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126168#M34366</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to connect to the basic alfresco repository using the CMIS API URL using Atompub or browser binding.&lt;/P&gt;&lt;P&gt;I tried connecting to the repository using the URLs provided in the alfresco documentation.&lt;/P&gt;&lt;P&gt;URLs :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pln"&gt;http&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="com"&gt;//&amp;lt;hostname&amp;gt;:&amp;lt;port&amp;gt;/alfresco/api/-default-/public/cmis/versions/1.1/atom&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class="pln"&gt;http&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="com"&gt;//&amp;lt;hostname&amp;gt;:&amp;lt;port&amp;gt;/alfresco/api/-default-/public/cmis/versions/1.1/browser&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;But I am facing an error related to http authentication&lt;/P&gt;&lt;PRE&gt;{
    "status" : 
  {
    "code" : 401,
    "name" : "Unauthorized",
    "description" : "The request requires HTTP authentication."
  },  
  
  "message" : "11210005 Authentication failed for Web Script org\/alfresco\/api\/opencmis\/OpenCMIS.get",  
  "exception" : "",
  
  "callstack" : 
  [ 
  	   
  ],
  
  "server" : "Enterprise v6.2.0 (ra498a911-b5) schema 13,001",
  "time" : "21 Dec 2020, 07:33:37"
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;How can I solve this error, where do I need to auntheticate this?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 07:46:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126168#M34366</guid>
      <dc:creator>Vishruti_Shah</dc:creator>
      <dc:date>2020-12-21T07:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting to basic alfresco repository using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126169#M34367</link>
      <description>&lt;P&gt;Try to call with basic authentication.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 09:59:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126169#M34367</guid>
      <dc:creator>sp2</dc:creator>
      <dc:date>2020-12-21T09:59:57Z</dc:date>
    </item>
    <item>
      <title>hereRe: Connecting to basic alfresco repository using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126170#M34368</link>
      <description>&lt;P&gt;Please paste your code here&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 13:01:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126170#M34368</guid>
      <dc:creator>kaynezhang</dc:creator>
      <dc:date>2020-12-21T13:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting to basic alfresco repository using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126171#M34369</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;{
    "status" : 
  {
    "code" : 401,
    "name" : "Unauthorized",
    "description" : "The request requires HTTP authentication."
  },  
  
  "message" : "11210005 Authentication failed for Web Script org\/alfresco\/api\/opencmis\/OpenCMIS.get",  
  "exception" : "",
  
  "callstack" : 
  [ 
  	   
  ],
  
  "server" : "Enterprise v6.2.0 (ra498a911-b5) schema 13,001",
  "time" : "21 Dec 2020, 07:33:37"
}&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your error indicates authentication failure, possible that you are using invalid credentials.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;There is another good way to work with CMIS api, read this tutorial:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#cmis-1.0-and-the-alfresco-opencmis-extension-library" target="_blank" rel="noopener nofollow noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#cmis-1.0-and-the-alfresco-opencmis-extension-library&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Example source code&lt;/U&gt;:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jpotts/alfresco-developer-series/tree/master/content/content-tutorial-cmis/src/main/java/com/someco/cmis/examples" target="_blank" rel="noopener nofollow noreferrer"&gt;https://github.com/jpotts/alfresco-developer-series/tree/master/content/content-tutorial-cmis/src/main/java/com/someco/cmis/examples&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;On the other hand, either of the URLs should work if you trying to access via some client. As indicated by the folks, you can use basic authentication or &lt;STRONG&gt;alf_ticket&lt;/STRONG&gt; (&lt;A href="https://docs.alfresco.com/5.0/references/RESTful-RepositoryLoginPost.html" target="_blank" rel="noopener nofollow noreferrer"&gt;get it using login api&lt;/A&gt;) to access the atompub url using any client/java code. Use the httppost request if using basic auth. It is not recommended to use basic auth with httpget in general.&lt;/P&gt;
&lt;PRE&gt;POST http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom&lt;/PRE&gt;
&lt;P&gt;Also refer this doc:&amp;nbsp;&lt;A href="https://docs.oasis-open.org/cmis/CMIS/v1.1/errata01/os/CMIS-v1.1-errata01-os-complete.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://docs.oasis-open.org/cmis/CMIS/v1.1/errata01/os/CMIS-v1.1-errata01-os-complete.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser" target="_self" rel="nofollow noopener noreferrer"&gt;this&lt;/A&gt; url based on browser binding is meant to be accessed from browser/httpget request. httpPost request is not supported for &lt;A href="http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser" target="_self" rel="nofollow noopener noreferrer"&gt;this&lt;/A&gt; url. Hence you can get the &lt;A href="https://docs.alfresco.com/5.0/references/RESTful-RepositoryLoginPost.html" target="_blank" rel="noopener nofollow noreferrer"&gt;alf_ticket&lt;/A&gt; and pass along with the url to access the endpoint:&lt;/P&gt;
&lt;P&gt;e.g.:&lt;/P&gt;
&lt;PRE&gt;GET http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser?alf_ticket=TICKET_8d8aa27acc731f99c77e3fb670c5c40a6642d039&lt;/PRE&gt;
&lt;PRE&gt;&lt;U&gt;&lt;STRONG&gt;Some java based httpclient examples for your reference:&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;
public static void main(String[] args) throws ClientProtocolException, IOException {
	//Basic auth example
	CloseableHttpClient httpclient = null;
	try {
		final CredentialsProvider provider = new BasicCredentialsProvider();&lt;BR /&gt;                //non admin user
		final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("testUser", "welcome");
		provider.setCredentials(AuthScope.ANY, credentials);
		httpclient = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
		atomPubTestBasicAuth(httpclient);
	} finally {
		if (httpclient != null) {
			httpclient.close();
		}
	}
	
	//Example via alf_ticket
	browserBindingTest();
}

private static void atomPubTestBasicAuth(final CloseableHttpClient httpclient) throws IOException, ClientProtocolException {
	System.out.println("Invoking atomPubTestBasicAuth..");&lt;BR /&gt;        //atompub url example
	final HttpPost httpPost = new HttpPost("http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom");
	try(CloseableHttpResponse httpResp = httpclient.execute(httpPost);) {
		if (httpResp != null) {
			final StatusLine statusLine = httpResp.getStatusLine();
			final String statusMsg = statusLine.getReasonPhrase();
			final int statusCode = statusLine.getStatusCode();
			System.out.println("StatusMsg: "+statusMsg+", StatusCode: "+statusCode);
			if (statusCode == 200) {
				// process further
				
			} else {
				//report error
			}
		}
	}
}

private static void browserBindingTest() throws IOException, ClientProtocolException {
	System.out.println("Invoking browserBindingTest..");
	try (final CloseableHttpClient httpclient = HttpClientBuilder.create().build();) {&lt;BR /&gt;                //example browser binding url
		final HttpGet httpGet = new HttpGet("http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser?alf_ticket=TICKET_8d8aa27acc731f99c77e3fb670c5c40a6642d039");
		try(CloseableHttpResponse httpResp = httpclient.execute(httpGet);) {
			if (httpResp != null) {
				final StatusLine statusLine = httpResp.getStatusLine();
				final String statusMsg = statusLine.getReasonPhrase();
				final int statusCode = statusLine.getStatusCode();
				System.out.println("StatusMsg: "+statusMsg+", StatusCode: "+statusCode);
				if (statusCode == 200) {
					// process further					
				} else {
					//report error
				}
			}
		}
	}
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Dec 2020 19:18:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/connecting-to-basic-alfresco-repository-using-cmis/m-p/126171#M34369</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-12-21T19:18:35Z</dc:date>
    </item>
  </channel>
</rss>

