How to Verify Basic Authorization Credentials Prior to Authenticating an Instance

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

Common Approaches to Basic Authentication

  1. Authenticate an adapter instance, and then make a subsequent API call to the adapter 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 adapter.  The benefits of this approach are that you avoid making the additional call from your backend to Sugar Integrate 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 adapter 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.