Use a GraphQL Endpoint

4min

Complete the steps below to use a GraphQL endpoint.

Step 1: Create Client

You will first need to log in to your Keycloak profile for Litmus UNS and create a new client.

To create a client:

  1. Access the Keycloak admin console at: https://<Litmus UNS hostname>/auth/admin.
  2. From the Keycloak Realm drop-down on the left, switch the realm to standalone.

    Keycloak realm side menu
    Keycloak realm side menu
    
  3. Navigate to Clients.
  4. Click Create client.
  5. Configure the General Settings.
    • Client type: Select OpenID Connect.
    • Client ID: Enter a client ID.
    • Name: Enter a name for the client.
    • Description: Enter a description for the client.
    • Always display in UI: Leave the default setting to turn off the setting to always display the client in the user interface.
  6. Click Next.
  7. Configure the Capability config settings.
    • Client authentication: Click the toggle to enable client authentication.
    • Authorization: Leave the default setting to turn off authorization.
    • Authentication flow: Click the checkbox for Standard flow, Direct access grants, and Service accounts roles.
  8. Click Next.
  9. Leave the Login settings empty and click Save. The new client is created.

Step 2: Create API Request

After creating the client in Keycloak, you will then create an API request through GraphQL by using Postman.

  1. In Clients, click the new client name.
  2. Click the Credentials tab.
  3. Click the Copy icon for the Client secret. You will refer to this later.
  4. Open the Postman application.
  5. Open your workspace in the left-navigation menu.

    Workspace icon
    Workspace icon
    
  6. Click the New Request icon.

    New Request icon
    New Request icon
    
  7. Click New.

    Document image
    
  8. Click GraphQL.

    Document image
    
  9. For the new request, enter the following URL: https://<Litmus UNS hostname>/mqtt/gql.

    Document image
    
  10. Click the Authorization tab.

    Document image
    
  11. For the Type, select OAuth 2.0.
  12. Enter the following details for Configure New Token.
    • Token Name: Enter a name for the token.
    • Grant type: Select Client Credentials.
    • Access Token URL: Enter the following URL: https://<Litmus UNS hostname>/auth/realms/standalone/protocol/openid-connect/token
    • Client secret: Paste the client secret copied previously.
  13. Click Get New Access Token and then Proceed.
  14. From the Manage Access Tokens dialog, click Use Token. The token is added to the request.

Step 3: Verify Version and Hash

Once the token added to the API request, you can verify the version and hash values.

  1. Click the Schema tab.

    Schema tab
    Schema tab
    
  2. Click Use GraphQL Introspection.

    Document image
    
  3. Click the Query tab.
  4. Click the checkbox for version. The checkboxes for version Version!, version String!, and hash String! should be selected.

    Document image
    
  5. Click Query. The response should display the version and hash values.
Document image