How to Verify Basic Authorization Credentials Prior to Authenticating an Instance

When building an element that utilizes basic authentication, there are two common approaches to verifying that the user credentials are correct.  Note that by default, authenticating an element instance using basic authentication does not verify the user credentials with the provider.

Common Approaches to Basic Authentication

  1. Authenticate an element instance, and then make a subsequent API call to the element to confirm it returns a 200 status code.  With this approach, the instance will need to be deleted if the API call does not return success.
  2. Abstract approach #1 into the element.  The benefits of this approach are that you avoid making the additional call from your backend to Cloud Elements to verify the user credentials. Instead you simply make the call to create the instance, and handle success or failure cases.  Details below.

The Abstract Approach

We recommend adding a new resource that will make a ‘test’ call to the instance during provisioning.  If the call is successful, the credentials are valid and the instance will be provisioned.  If the call is unsuccessful, an error will be returned.

  1. From the element configuration, click Resources.
  2. Add a new resource called "on-provision".
  3. Map the new resource to any GET all endpoint.
  4. Select On Provision from the resource type list.