Sitecore Content Hub External Integrations

There are 2 ways to integrate with Sitecore Content Hub from an external application:
  1. WebClient SDK
  2. REST API
Some would say No rest for the ... well good. While others are very happy with a little rest. It all depends on your needs. If you are working in with .NET I highly recommend WebClient SDK. It wraps a lot of the complexities and is more secure.

If you have not seen Good Omens then I highly recommend watching this as there will be hints of references to Good Omens throughout my blog articles and the Symposium Presentation on Sitecore Content Hub.


REST API

The REST API method requires no additional library references as you are simply hitting them via https. You do need a token which needs to be generated in Sitecore Content Hub. This is done by clicking on Manage and Users.


On the specific user click on the key beside their name. If the user is already has a REST API key generated then you will see the notification in their user row. saying API USER. If that is the case then be careful.

A few words of WARNING.

  1. It will not let you view the key. If a key does not exist you can create one. If it does you can recreate it. This will give you a new key and the old one will expire so any applications using it would need to change the key.
  2. If you create a token for a user then you cannot use the same user for OAuth and the WebClient SDK. It will not warn you about this only throw a token error for OAuth so ensure you have different users for REST API and WebClient SDK.
If you are looking at using the REST API, I have an example .NET Core Console Application called SchBasicCoreConsole in the SchGuild GitHub.

WebClient SDK

This is my preferred method. In order to use this option you will need access to the Nuget packages. These can be found here however you need permissions to access them. I simply registered, it sent me an email then I logged in and downloaded the packages. The official documentation on WebClient SDK provides instructions if you want to set up an http source to it.

If you are looking at the reference repository available at https://github.com/STYLELABS/cloud-dev-examples then you will have to update the packages as there are now 3.2.2 packages and it is using 2.9.0458.

In order to use the WebClient SDK you need to register an OAuth in the Manage section of Sitecore Content Hub. Watch the YouTube video below to see how to do this.


If you are looking at using the WebClient SDK, I have started creating C# Scripts you can run locally or copy to Content Hub as part of your internal scripts. This is a work in progress so not all scripts will be there yet but you can check them out at  SchGuild GitHub.

No comments:

Post a Comment