The goal of this example is to help you successfully use a web application to authenticate and make a call to the BarTender Cloud REST API. This example describes the changes that are required to convert the generic C# web application into one that can you can use to interact directly with BarTender Cloud, and it provides code snippets that demonstrate how to connect to endpoints for the Librarian API.
Note: To begin the example, you must first register your web application and have access to your application ID and secret. For more information about how to register your web application, refer to Authentication.
For the purposes of this example, specify the following registration parameters:
-
Login URI: https://mycustom-domain.com/login
-
Callback List: https://mycustom-domain.com, https://mycustom-domain.com/callback, https://mycustom-domain.com/
-
Logout URLs: https://mycustom-domain.com or https://mycustom-domain.com/logout
|
To use this example, you must have Microsoft Visual Studio 2022 and .NET Core 6.0 installed.
In addition, the following items are required:
-
LibrarianWebApp C# project: This is a generic C# web application that you will configure so that it can interact with the BarTender Cloud API. This model-view-controller (MVC) sample application was built by using Microsoft Visual Studio 2022 and .NET Core 6.0.
-
Supporting files: The following files are required for updating the LibrarianWebApp project:
-
LibrarianController.cs
-
Space.cs
-
Spaces.cshtml
-
User.cs
You can download these items from the following web page:
https://help.seagullscientific.com/BarTenderCloud/Content/Samples/CSharpSampleApplication/CSharpSampleApp_RequiredFiles.zip
The following terms are used throughout the example:
-
Audience: The determiner of the target interfaces of the access token. An analogy might be that the access token is your company ID badge. The audience that is embedded within the token determines which doors you can open.
-
Authorization server: A web service that is responsible for authenticating a user when they sign in and for issuing a secure Java Web Token in response.
-
ClientID: A unique identifier for your web application that is used with the authorization server to differentiate one application from another. It is important to not disclose this value publicly.
-
ClientSecret: A long unique string that is used to prove ownership of the ClientID. As with the ClientID, the value should not be shared publicly. Together with the ClientID, the ClientSecret allows your web application to share information securely with the authorization server.
-
Java Web Token (JWT): A signed object that represents an access token. When a user successfully signs in to BarTender Cloud, an access token is created. A web application provides this token when it tries to make a REST call to a BarTender Cloud API. Services that implement the BarTender Cloud API leverage this access token to identify the user on whose behalf an API is being called.
In This Section
-
Enable Authentication
Describes the updates that you must make to the sample LibrarianWebApp application to sign in and out of BarTender Cloud.
-
Enable User Interface Requirements
Describes how to add a controller and its associated UI, which provides the actual functionality for signing in and out.
-
Call the Librarian API
Describes how to update the project code so that you can place a REST call to the BarTender Cloud Librarian API.