Basic Authentication with samples
As of Adaptix 2.3.0, support for basic authentication can be enabled through Adaptix's Configuration -> API Settings. As with OAuth2, it is only recommended to use basic authentication over HTTPS.
To authorize a request for basic authentication, set an Authorization
header.
- Combine the username and password of a Adaptix user with a colon
:
. For example,user:password
. - Base64 encode the string from above.
dXNlcjpwYXNzd29yZA==
. - Add an Authorization header to each API request as
Authorization: Basic dXNlcjpwYXNzd29yZA==
- The URL should be a known endopoint i.e.
api/contacts
CURL example
PHP example
$settings will be an array like this:
Also, for basic auth, pass 'BasicAuth' in 2nd parameter:
Java example
Make a GET request with Basic Authentication to the endpoint https://instancename.adaptix.ai/api/contacts
using HttpURLConnection
:
JavaScript example
Using fetch()
to make a GET request with Basic Authentication to:
-
btoa()
encodes the username and password into a base64 string as required by Basic Auth. -
Always use
HTTPS
when sending credentials. -
If you're working in Node.js, you can use
node-fetch
or Axios with similar logic.
Python example
Using the requests
library to make a GET request with Basic Authentication to:
Make sure requests
is installed:
instancename
with your actual subdomain.
All the above example returns the Contacts list in JSON like the following,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|