Skip to content

Commit 4264fd5

Browse files
author
Niall Brennan
committed
Add basic auth with writekey auth
1 parent adee552 commit 4264fd5

File tree

1 file changed

+23
-1
lines changed
  • src/connections/sources/catalog/libraries/server/http-api

1 file changed

+23
-1
lines changed

src/connections/sources/catalog/libraries/server/http-api/index.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,34 @@ Segment has native [sources](/docs/connections/sources/) for most use cases (lik
1111

1212
### Authentication
1313

14-
Choose between [writeKey authentication](#writeKey-authentication) and [OAuth](#oauth) to authenticate requests.
14+
Choose between [writeKey authentication](#writeKey-authentication), [basic authentication](#basic-authentication) and [OAuth](#oauth) to authenticate requests.
1515

1616
#### writeKey authentication
1717
Authenticate to the Tracking API by sending your project's **Write Key** along with a request.
1818
The authentication writeKey should be sent as part of the body of the request. This will be encrypted over https.
1919

20+
```
21+
curl --location 'https://api.segment.io/v1/track' \
22+
--header 'Content-Type: application/json' \
23+
--data-raw '{
24+
"event": "happy-path-a3ef8a6f-0482-4694-bc4d-4afba03a0eab",
25+
"email": "[email protected]",
26+
"userId": "123",
27+
"writeKey": "sx1dTUoxt8oErcWt1S1H23IZnr9SSRhy"
28+
}'
29+
```
30+
31+
> info ""
32+
> For this auth type, you do not need to set any authentication header.
33+
34+
#### Basic authentication
35+
Basic authentication uses HTTP Basic Auth, which involves a `username:password` that is base64 encoded and prepended with the string `Basic`.
36+
37+
In practice that means taking a Segment source **Write Key**,`'abc123'`, as the username, adding a colon, and then the password field is left empty. After base64 encoding `'abc123:'` becomes `'YWJjMTIzOg=='`; and this is passed in the authorization header like so: `'Authorization: Basic YWJjMTIzOg=='`.
38+
39+
> info ""
40+
> Include a colon before encoding. While encoding the write key without a colon might work due to backward compatibility, this won't always be the case.
41+
2042
#### OAuth
2143
[Obtain the access token](/docs/connections/oauth/) from the Authorization Server specific to the region.
2244

0 commit comments

Comments
 (0)