---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [auth](../index.md) / BasicAuthStrategy

# Class: BasicAuthStrategy

Defined in: [packages/b2c-tooling-sdk/src/auth/basic.ts:24](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/67fb8580ac3c5b372617ee3ec3fc8f2bc9f16174/packages/b2c-tooling-sdk/src/auth/basic.ts#L24)

Basic authentication strategy for WebDAV operations.

Encodes username and access key as Base64 for HTTP Basic auth.
Implements the [AuthStrategy](../interfaces/AuthStrategy.md) interface.

## Example

```typescript
import { BasicAuthStrategy } from '@salesforce/b2c-tooling-sdk';

const auth = new BasicAuthStrategy('username', 'access-key');
const response = await auth.fetch('https://webdav.example.com/path');
```

## Implements

- [`AuthStrategy`](../interfaces/AuthStrategy.md)

## Constructors

### Constructor

> **new BasicAuthStrategy**(`user`, `pass`): `BasicAuthStrategy`

Defined in: [packages/b2c-tooling-sdk/src/auth/basic.ts:33](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/67fb8580ac3c5b372617ee3ec3fc8f2bc9f16174/packages/b2c-tooling-sdk/src/auth/basic.ts#L33)

Creates a new BasicAuthStrategy instance for HTTP Basic authentication.

#### Parameters

##### user

`string`

The username for Basic authentication

##### pass

`string`

The password or access key for Basic authentication

#### Returns

`BasicAuthStrategy`

## Methods

### fetch()

> **fetch**(`url`, `init`): `Promise`\<`Response`\>

Defined in: [packages/b2c-tooling-sdk/src/auth/basic.ts:40](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/67fb8580ac3c5b372617ee3ec3fc8f2bc9f16174/packages/b2c-tooling-sdk/src/auth/basic.ts#L40)

Performs a fetch request with authentication.
Implementations MUST handle header injection and 401 retries (token refresh) internally.

#### Parameters

##### url

`string`

##### init

[`FetchInit`](../type-aliases/FetchInit.md) = `{}`

#### Returns

`Promise`\<`Response`\>

#### Implementation of

[`AuthStrategy`](../interfaces/AuthStrategy.md).[`fetch`](../interfaces/AuthStrategy.md#fetch)

***

### getAuthorizationHeader()

> **getAuthorizationHeader**(): `Promise`\<`string`\>

Defined in: [packages/b2c-tooling-sdk/src/auth/basic.ts:47](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/67fb8580ac3c5b372617ee3ec3fc8f2bc9f16174/packages/b2c-tooling-sdk/src/auth/basic.ts#L47)

Optional: Helper for legacy clients (like a strict WebDAV lib) that need the raw header.

#### Returns

`Promise`\<`string`\>

#### Implementation of

[`AuthStrategy`](../interfaces/AuthStrategy.md).[`getAuthorizationHeader`](../interfaces/AuthStrategy.md#getauthorizationheader)
